GEOS  3.8.0dev
util.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Utility header to retain a bit of backward compatibility.
17  * Try to avoid including this header directly.
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_UTIL_H
22 #define GEOS_UTIL_H
23 
24 //#include <geos/util/AssertionFailedException.h>
25 #include <geos/util/GEOSException.h>
26 #include <geos/util/IllegalArgumentException.h>
27 #include <geos/util/TopologyException.h>
28 //#include <geos/util/UnsupportedOperationException.h>
29 //#include <geos/util/CoordinateArrayFilter.h>
30 //#include <geos/util/UniqueCoordinateArrayFilter.h>
31 #include <geos/util/GeometricShapeFactory.h>
32 //#include <geos/util/math.h>
33 
34 #include <memory>
35 
36 //
37 // Private macros definition
38 //
39 
40 namespace geos {
41 template<class T>
42 void
43 ignore_unused_variable_warning(T const &) {}
44 
45 namespace detail {
46 #if __cplusplus >= 201402L
47 using std::make_unique;
48 #else
49 // Backport of std::make_unique to C++11
50 // Source: https://stackoverflow.com/a/19472607
51 template<class T>
52 struct _Unique_if {
53  typedef std::unique_ptr<T> _Single_object;
54 };
55 
56 template<class T>
57 struct _Unique_if<T[]> {
58  typedef std::unique_ptr<T[]> _Unknown_bound;
59 };
60 
61 template<class T, size_t N>
62 struct _Unique_if<T[N]> {
63  typedef void _Known_bound;
64 };
65 
66 template<class T, class... Args>
67 typename _Unique_if<T>::_Single_object
68 make_unique(Args &&... args) {
69  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
70 }
71 
72 template<class T>
73 typename _Unique_if<T>::_Unknown_bound
74 make_unique(size_t n) {
75  typedef typename std::remove_extent<T>::type U;
76  return std::unique_ptr<T>(new U[n]());
77 }
78 
79 template<class T, class... Args>
80 typename _Unique_if<T>::_Known_bound
81 make_unique(Args &&...) = delete;
82 
83 #endif
84 }
85 }
86 
87 #endif // GEOS_UTIL_H
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25