GEOS 3.12.0
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
32namespace geos {
33template<class T>
34void
35ignore_unused_variable_warning(T const &) {}
36
37namespace detail {
38using std::make_unique;
39
49template<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 geos.h:39