GEOS  3.13.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 <cassert>
25 #include <memory>
26 #include <type_traits>
27 
28 //
29 // Private macros definition
30 //
31 
32 namespace geos {
33 template<class T>
34 void
35 ignore_unused_variable_warning(T const &) {}
36 
37 namespace detail {
38 using std::make_unique;
39 
49 template<typename To, typename From> inline To down_cast(From* f)
50 {
51  static_assert(
52  (std::is_base_of<From,
53  typename std::remove_pointer<To>::type>::value),
54  "target type not derived from source type");
55 #if GEOS_DEBUG
56  assert(f == nullptr || dynamic_cast<To>(f) != nullptr);
57 #endif
58  return static_cast<To>(f);
59 }
60 
61 } // namespace detail
62 } // namespace geos
63 
64 #endif // GEOS_UTIL_H
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25