3 // Copyright (c) 2020, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP
11 #define BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP
15 #include <type_traits>
18 namespace boost { namespace geometry
28 using bool_constant = std::integral_constant<bool, B>;
32 using int_constant = std::integral_constant<int, I>;
35 template <std::size_t I>
36 using index_constant = std::integral_constant<std::size_t, I>;
39 template <std::size_t S>
40 using size_constant = std::integral_constant<std::size_t, S>;
44 template <typename ...>
48 template<typename Trait>
49 struct conjunction<Trait>
52 template <typename Trait, typename ...Traits>
53 struct conjunction<Trait, Traits...>
54 : std::conditional_t<Trait::value, conjunction<Traits...>, Trait>
58 template <typename ...>
62 template <typename Trait>
63 struct disjunction<Trait>
66 template <typename Trait, typename ...Traits>
67 struct disjunction<Trait, Traits...>
68 : std::conditional_t<Trait::value, Trait, disjunction<Traits...>>
72 template <typename Trait>
74 : bool_constant<!Trait::value>
80 template <typename ...Traits>
81 using and_ = conjunction<Traits...>;
83 template <typename ...Traits>
84 using or_ = disjunction<Traits...>;
86 template <typename Trait>
87 using not_ = negation<Trait>;
95 using type = std::remove_cv_t<std::remove_reference_t<T>>;
99 using remove_cvref_t = typename remove_cvref<T>::type;
102 template <typename T>
105 using type = std::remove_const_t<std::remove_reference_t<T>>;
108 template <typename T>
109 using remove_cref_t = typename remove_cref<T>::type;
112 template <typename T>
113 struct remove_cptrref
115 using type = std::remove_const_t
117 std::remove_pointer_t<std::remove_reference_t<T>>
121 template <typename T>
122 using remove_cptrref_t = typename remove_cptrref<T>::type;
126 template <typename From, typename To>
127 struct transcribe_const
129 using type = std::conditional_t
131 std::is_const<std::remove_reference_t<From>>::value,
132 std::add_const_t<To>,
137 template <typename From, typename To>
138 using transcribe_const_t = typename transcribe_const<From, To>::type;
144 // Deprecated utilities, defined for backward compatibility but might be
145 // removed in the future.
149 \brief Meta-function to define a const or non const type
151 \details If the boolean template parameter is true, the type parameter
152 will be defined as const, otherwise it will be defined as it was.
153 This meta-function is used to have one implementation for both
154 const and non const references
155 \note This traits class is completely independant from Boost.Geometry
156 and might be a separate addition to Boost
157 \note Used in a.o. for_each, interior_rings, exterior_ring
160 void foo(typename add_const_if_c<IsConst, Point>::type& point)
163 template <bool IsConst, typename Type>
164 struct add_const_if_c
166 typedef std::conditional_t
178 template <typename T>
179 using bare_type = remove_cptrref<T>;
184 }} // namespace boost::geometry
186 #endif // BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP