Divide type_traits, replace bare_type with remove_cptrref.

Divide type_traits into two groups:
- util/type_traits_std.hpp - dependant only on std type_traits
- util/type_traits.hpp - dependant on geometry tags, also including the
above.

Add remove_cptrref and use it instead of bare_type.

For now keep bare_type, move it to util/type_traits_std.hpp.
This commit is contained in:
Adam Wulkiewicz
2020-09-03 19:32:01 +02:00
parent 00f00369cd
commit 9b09cd2efa
17 changed files with 275 additions and 237 deletions

View File

@@ -20,14 +20,13 @@
#include <cstddef>
#include <type_traits>
#include <boost/mpl/assert.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -277,7 +276,7 @@ constexpr inline typename coordinate_type<Geometry>::type get(Geometry const& ge
typedef core_dispatch::access
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type,
typename coordinate_type<Geometry>::type,
Dimension,
typename std::is_pointer<Geometry>::type
@@ -310,7 +309,7 @@ inline void set(Geometry& geometry
typedef core_dispatch::access
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type,
typename coordinate_type<Geometry>::type,
Dimension,
typename std::is_pointer<Geometry>::type
@@ -343,7 +342,7 @@ constexpr inline typename coordinate_type<Geometry>::type get(Geometry const& ge
typedef core_dispatch::indexed_access
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type,
typename coordinate_type<Geometry>::type,
Index,
Dimension,
@@ -378,7 +377,7 @@ inline void set(Geometry& geometry
typedef core_dispatch::indexed_access
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type,
typename coordinate_type<Geometry>::type,
Index,
Dimension,

View File

@@ -19,15 +19,13 @@
#ifndef BOOST_GEOMETRY_CORE_CLOSURE_HPP
#define BOOST_GEOMETRY_CORE_CLOSURE_HPP
#include <type_traits>
#include <boost/mpl/assert.hpp>
#include <boost/range/value_type.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
{
@@ -196,7 +194,7 @@ struct closure
static const closure_selector value = core_dispatch::closure
<
typename tag<Geometry>::type,
typename util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::value;
};

View File

@@ -20,13 +20,12 @@
#include <cstddef>
#include <type_traits>
#include <boost/mpl/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
{
@@ -68,13 +67,13 @@ struct dimension<point_tag, P>
: std::integral_constant
<
std::size_t,
traits::dimension<typename geometry::util::bare_type<P>::type>::value
traits::dimension<detail::remove_cptrref_t<P>>::value
>
{
BOOST_MPL_ASSERT_MSG(
(traits::dimension<typename geometry::util::bare_type<P>::type>::value > 0),
(traits::dimension<detail::remove_cptrref_t<P>>::value > 0),
INVALID_DIMENSION_VALUE,
(traits::dimension<typename geometry::util::bare_type<P>::type>)
(traits::dimension<detail::remove_cptrref_t<P>>)
);
};
@@ -93,7 +92,7 @@ struct dimension
: core_dispatch::dimension
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>
{};

View File

@@ -4,6 +4,10 @@
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -18,7 +22,7 @@
#include <boost/mpl/assert.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -67,7 +71,7 @@ namespace core_dispatch
{
typedef typename traits::coordinate_system
<
typename geometry::util::bare_type<Point>::type
typename detail::remove_cptrref<Point>::type
>::type type;
};
@@ -89,7 +93,7 @@ struct coordinate_system
typedef typename core_dispatch::coordinate_system
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::type type;
};

View File

@@ -4,6 +4,10 @@
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -19,8 +23,8 @@
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/promote_floating_point.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -66,7 +70,7 @@ struct coordinate_type<point_tag, Point>
{
typedef typename traits::coordinate_type
<
typename geometry::util::bare_type<Point>::type
typename detail::remove_cptrref<Point>::type
>::type type;
};
@@ -86,10 +90,10 @@ template <typename Geometry>
struct coordinate_type
{
typedef typename core_dispatch::coordinate_type
<
typename tag<Geometry>::type,
typename geometry::util::bare_type<Geometry>::type
>::type type;
<
typename tag<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type
>::type type;
};
template <typename Geometry>

View File

@@ -4,8 +4,8 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2014.
// Modifications copyright (c) 2014 Oracle and/or its affiliates.
// This file was modified by Oracle on 2014-2020.
// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@@ -26,7 +26,7 @@
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
{
@@ -178,7 +178,7 @@ struct point_order
static const order_selector value = core_dispatch::point_order
<
typename tag<Geometry>::type,
typename util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::value;
};

View File

@@ -19,15 +19,13 @@
#define BOOST_GEOMETRY_CORE_POINT_TYPE_HPP
#include <type_traits>
#include <boost/mpl/assert.hpp>
#include <boost/range/value_type.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -157,7 +155,7 @@ struct point_type
typedef typename core_dispatch::point_type
<
typename tag<Geometry>::type,
typename boost::geometry::util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::type type;
};

View File

@@ -22,13 +22,12 @@
#include <cstddef>
#include <type_traits>
#include <boost/static_assert.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -111,7 +110,7 @@ struct radius_type
typedef typename core_dispatch::radius_type
<
typename tag<Geometry>::type,
typename util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::type type;
};
@@ -128,7 +127,7 @@ inline typename radius_type<Geometry>::type get_radius(Geometry const& geometry)
return core_dispatch::radius_access
<
typename tag<Geometry>::type,
typename util::bare_type<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type,
I,
typename std::is_pointer<Geometry>::type
>::get(geometry);
@@ -148,7 +147,7 @@ inline void set_radius(Geometry& geometry,
core_dispatch::radius_access
<
typename tag<Geometry>::type,
typename util::bare_type<Geometry>::type,
typename detail::remove_cptrref<Geometry>::type,
I,
typename std::is_pointer<Geometry>::type
>::set(geometry, radius);

View File

@@ -4,6 +4,10 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -16,7 +20,7 @@
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -60,7 +64,7 @@ struct tag
{
typedef typename traits::tag
<
typename geometry::util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::type type;
};

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2018.
// Modifications copyright (c) 2018 Oracle and/or its affiliates.
// This file was modified by Oracle on 2018-2020.
// Modifications copyright (c) 2018-2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
@@ -19,14 +19,11 @@
#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_CORE_COORDINATE_DIMENSION_HPP
#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_CORE_COORDINATE_DIMENSION_HPP
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/extensions/algebra/core/tags.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/extensions/algebra/core/tags.hpp>
namespace boost { namespace geometry {
namespace traits {
@@ -36,7 +33,7 @@ struct indexed_dimension
{
BOOST_MPL_ASSERT_MSG(false,
NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_OR_INDEX,
(Geometry, boost::integral_constant<std::size_t, Index>));
(Geometry, std::integral_constant<std::size_t, Index>));
};
} // namespace traits
@@ -46,12 +43,12 @@ namespace core_dispatch {
template <typename V>
struct dimension<vector_tag, V>
: traits::dimension<typename geometry::util::bare_type<V>::type>
: traits::dimension<typename detail::remove_cptrref<V>::type>
{};
template <typename G>
struct dimension<quaternion_tag, G>
: traits::dimension<typename geometry::util::bare_type<G>::type>
: traits::dimension<typename detail::remove_cptrref<G>::type>
{};
template <typename T, typename G, std::size_t Index>
@@ -59,23 +56,23 @@ struct indexed_dimension
{
BOOST_MPL_ASSERT_MSG(false,
NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_OR_INDEX,
(G, boost::integral_constant<std::size_t, Index>));
(G, std::integral_constant<std::size_t, Index>));
};
template <typename G, std::size_t Index>
struct indexed_dimension<matrix_tag, G, Index>
: traits::indexed_dimension<typename geometry::util::bare_type<G>::type, Index>
: traits::indexed_dimension<typename detail::remove_cptrref<G>::type, Index>
{};
template <typename G>
struct dimension<rotation_quaternion_tag, G>
: traits::dimension<typename geometry::util::bare_type<G>::type>
: traits::dimension<typename detail::remove_cptrref<G>::type>
{};
template <typename G>
struct dimension<rotation_matrix_tag, G>
: traits::dimension<typename geometry::util::bare_type<G>::type>
: traits::dimension<typename detail::remove_cptrref<G>::type>
{};
} // namespace core_dispatch

View File

@@ -5,6 +5,10 @@
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -16,7 +20,6 @@
#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_CORE_COORDINATE_SYSTEM_HPP
#include <boost/geometry/core/coordinate_system.hpp>
#include <boost/geometry/extensions/algebra/core/tags.hpp>
namespace boost { namespace geometry {
@@ -28,7 +31,7 @@ template <typename Vector>
struct coordinate_system<vector_tag, Vector>
{
typedef typename traits::coordinate_system<
typename geometry::util::bare_type<Vector>::type
typename detail::remove_cptrref<Vector>::type
>::type type;
};
@@ -36,7 +39,7 @@ struct coordinate_system<vector_tag, Vector>
//struct coordinate_system<quaternion_tag, G>
//{
// typedef typename traits::coordinate_system<
// typename geometry::util::bare_type<G>::type
// typename detail::remove_cptrref<G>::type
// >::type type;
//};
//
@@ -44,7 +47,7 @@ struct coordinate_system<vector_tag, Vector>
//struct coordinate_system<matrix_tag, G>
//{
// typedef typename traits::coordinate_system<
// typename geometry::util::bare_type<G>::type
// typename detail::remove_cptrref<G>::type
// >::type type;
//};
@@ -53,7 +56,7 @@ template <typename G>
struct coordinate_system<rotation_quaternion_tag, G>
{
typedef typename traits::coordinate_system<
typename geometry::util::bare_type<G>::type
typename detail::remove_cptrref<G>::type
>::type type;
};
@@ -61,7 +64,7 @@ template <typename G>
struct coordinate_system<rotation_matrix_tag, G>
{
typedef typename traits::coordinate_system<
typename geometry::util::bare_type<G>::type
typename detail::remove_cptrref<G>::type
>::type type;
};

View File

@@ -5,6 +5,10 @@
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -16,7 +20,6 @@
#define BOOST_GEOMETRY_EXTENSIONS_ALGEBRA_CORE_COORDINATE_TYPE_HPP
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/extensions/algebra/core/tags.hpp>
namespace boost { namespace geometry {
@@ -28,7 +31,7 @@ template <typename Vector>
struct coordinate_type<vector_tag, Vector>
{
typedef typename traits::coordinate_type<
typename geometry::util::bare_type<Vector>::type
typename detail::remove_cptrref<Vector>::type
>::type type;
};
@@ -36,7 +39,7 @@ template <typename G>
struct coordinate_type<quaternion_tag, G>
{
typedef typename traits::coordinate_type<
typename geometry::util::bare_type<G>::type
typename detail::remove_cptrref<G>::type
>::type type;
};
@@ -44,7 +47,7 @@ template <typename G>
struct coordinate_type<matrix_tag, G>
{
typedef typename traits::coordinate_type<
typename geometry::util::bare_type<G>::type
typename detail::remove_cptrref<G>::type
>::type type;
};
@@ -53,7 +56,7 @@ template <typename G>
struct coordinate_type<rotation_quaternion_tag, G>
{
typedef typename traits::coordinate_type<
typename geometry::util::bare_type<G>::type
typename detail::remove_cptrref<G>::type
>::type type;
};
@@ -61,7 +64,7 @@ template <typename G>
struct coordinate_type<rotation_matrix_tag, G>
{
typedef typename traits::coordinate_type<
typename geometry::util::bare_type<G>::type
typename detail::remove_cptrref<G>::type
>::type type;
};

View File

@@ -22,7 +22,6 @@
#include <cstddef>
#include <string>
#include <type_traits>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
@@ -47,15 +46,16 @@
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/geometry/core/mutable_range.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/util/coordinate_cast.hpp>
#include <boost/geometry/io/wkt/detail/prefix.hpp>
#include <boost/geometry/util/coordinate_cast.hpp>
#include <boost/geometry/util/type_traits.hpp>
namespace boost { namespace geometry
{
@@ -264,14 +264,10 @@ struct stateful_range_appender<Geometry, open>
typedef typename geometry::point_type<Geometry>::type point_type;
typedef typename boost::range_size
<
typename util::bare_type<Geometry>::type
typename detail::remove_cptrref<Geometry>::type
>::type size_type;
BOOST_STATIC_ASSERT(( std::is_same
<
typename tag<Geometry>::type,
ring_tag
>::value ));
BOOST_STATIC_ASSERT(( detail::is_ring<Geometry>::value ));
inline stateful_range_appender()
: pt_index(0)

View File

@@ -12,12 +12,11 @@
#define BOOST_GEOMETRY_ITERATORS_DETAIL_SEGMENT_ITERATOR_VALUE_TYPE_HPP
#include <iterator>
#include <type_traits>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/geometries/pointing_segment.hpp>
#include <boost/geometry/iterators/point_iterator.hpp>
#include <boost/geometry/util/bare_type.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
{
@@ -53,7 +52,7 @@ struct value_type
geometry::model::pointing_segment<point_iterator_value_type>,
geometry::model::segment
<
typename geometry::util::bare_type
typename detail::remove_cptrref
<
point_iterator_value_type
>::type

View File

@@ -16,32 +16,10 @@
#define BOOST_GEOMETRY_UTIL_BARE_TYPE_HPP
#include <type_traits>
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("<boost/geometry/util/type_traits.hpp>")
namespace boost { namespace geometry
{
namespace util
{
template <typename T>
struct bare_type
{
typedef std::remove_const_t
<
std::remove_pointer_t
<
std::remove_reference_t<T>
>
> type;
};
} // namespace util
}} // namespace boost::geometry
#include <boost/geometry/util/type_traits.hpp>
#endif // BOOST_GEOMETRY_UTIL_BARE_TYPE_HPP

View File

@@ -11,11 +11,9 @@
#define BOOST_GEOMETRY_UTIL_TYPE_TRAITS_HPP
#include <cstddef>
#include <type_traits>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
@@ -27,70 +25,6 @@ namespace detail
{
// C++17
template <bool B>
using bool_constant = std::integral_constant<bool, B>;
// non-standard
template <int I>
using int_constant = std::integral_constant<int, I>;
// non-standard
template <std::size_t I>
using index_constant = std::integral_constant<std::size_t, I>;
// non-standard
template <std::size_t S>
using size_constant = std::integral_constant<std::size_t, S>;
// C++17
template <typename ...>
struct conjunction
: std::true_type
{};
template<typename Trait>
struct conjunction<Trait>
: Trait
{};
template <typename Trait, typename ...Traits>
struct conjunction<Trait, Traits...>
: std::conditional_t<Trait::value, conjunction<Traits...>, Trait>
{};
// C++17
template <typename ...>
struct disjunction
: std::false_type
{};
template <typename Trait>
struct disjunction<Trait>
: Trait
{};
template <typename Trait, typename ...Traits>
struct disjunction<Trait, Traits...>
: std::conditional_t<Trait::value, Trait, disjunction<Traits...>>
{};
// C++17
template <typename Trait>
struct negation
: bool_constant<!Trait::value>
{};
/*
template <typename ...Traits>
using and_ = conjunction<Traits...>;
template <typename ...Traits>
using or_ = disjunction<Traits...>;
template <typename Trait>
using not_ = negation<Trait>;
*/
template <typename T>
struct is_geometry
: bool_constant<! std::is_void<typename tag<T>::type>::value>
@@ -288,75 +222,10 @@ template <typename Geometry, typename T = void>
using enable_if_polysegmental_t = typename enable_if_polysegmental<Geometry, T>::type;
// C++20
template <typename T>
struct remove_cvref
{
using type = std::remove_cv_t<std::remove_reference_t<T>>;
};
template <typename T>
using remove_cvref_t = typename remove_cvref<T>::type;
// non-standard
template <typename T>
struct remove_cref
{
using type = std::remove_const_t<std::remove_reference_t<T>>;
};
template <typename T>
using remove_cref_t = typename remove_cref<T>::type;
template <typename From, typename To>
struct transcribe_const
{
using type = std::conditional_t
<
std::is_const<std::remove_reference_t<From>>::value,
std::add_const_t<To>,
To
>;
};
template <typename From, typename To>
using transcribe_const_t = typename transcribe_const<From, To>::type;
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
/*!
\brief Meta-function to define a const or non const type
\ingroup utility
\details If the boolean template parameter is true, the type parameter
will be defined as const, otherwise it will be defined as it was.
This meta-function is used to have one implementation for both
const and non const references
\note This traits class is completely independant from Boost.Geometry
and might be a separate addition to Boost
\note Used in a.o. for_each, interior_rings, exterior_ring
\par Example
\code
void foo(typename add_const_if_c<IsConst, Point>::type& point)
\endcode
*/
template <bool IsConst, typename Type>
struct add_const_if_c
{
typedef std::conditional_t
<
IsConst,
Type const,
Type
> type;
};
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_DETAIL_HPP

View File

@@ -0,0 +1,188 @@
// Boost.Geometry
// Copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP
#define BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP
#include <cstddef>
#include <type_traits>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
// C++17
template <bool B>
using bool_constant = std::integral_constant<bool, B>;
// non-standard
template <int I>
using int_constant = std::integral_constant<int, I>;
// non-standard
template <std::size_t I>
using index_constant = std::integral_constant<std::size_t, I>;
// non-standard
template <std::size_t S>
using size_constant = std::integral_constant<std::size_t, S>;
// C++17
template <typename ...>
struct conjunction
: std::true_type
{};
template<typename Trait>
struct conjunction<Trait>
: Trait
{};
template <typename Trait, typename ...Traits>
struct conjunction<Trait, Traits...>
: std::conditional_t<Trait::value, conjunction<Traits...>, Trait>
{};
// C++17
template <typename ...>
struct disjunction
: std::false_type
{};
template <typename Trait>
struct disjunction<Trait>
: Trait
{};
template <typename Trait, typename ...Traits>
struct disjunction<Trait, Traits...>
: std::conditional_t<Trait::value, Trait, disjunction<Traits...>>
{};
// C++17
template <typename Trait>
struct negation
: bool_constant<!Trait::value>
{};
// non-standard
/*
template <typename ...Traits>
using and_ = conjunction<Traits...>;
template <typename ...Traits>
using or_ = disjunction<Traits...>;
template <typename Trait>
using not_ = negation<Trait>;
*/
// C++20
template <typename T>
struct remove_cvref
{
using type = std::remove_cv_t<std::remove_reference_t<T>>;
};
template <typename T>
using remove_cvref_t = typename remove_cvref<T>::type;
// non-standard
template <typename T>
struct remove_cref
{
using type = std::remove_const_t<std::remove_reference_t<T>>;
};
template <typename T>
using remove_cref_t = typename remove_cref<T>::type;
// non-standard
template <typename T>
struct remove_cptrref
{
using type = std::remove_const_t
<
std::remove_pointer_t<std::remove_reference_t<T>>
>;
};
template <typename T>
using remove_cptrref_t = typename remove_cptrref<T>::type;
// non-standard
template <typename From, typename To>
struct transcribe_const
{
using type = std::conditional_t
<
std::is_const<std::remove_reference_t<From>>::value,
std::add_const_t<To>,
To
>;
};
template <typename From, typename To>
using transcribe_const_t = typename transcribe_const<From, To>::type;
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
// Deprecated utilities, defined for backward compatibility but might be
// removed in the future.
/*!
\brief Meta-function to define a const or non const type
\ingroup utility
\details If the boolean template parameter is true, the type parameter
will be defined as const, otherwise it will be defined as it was.
This meta-function is used to have one implementation for both
const and non const references
\note This traits class is completely independant from Boost.Geometry
and might be a separate addition to Boost
\note Used in a.o. for_each, interior_rings, exterior_ring
\par Example
\code
void foo(typename add_const_if_c<IsConst, Point>::type& point)
\endcode
*/
template <bool IsConst, typename Type>
struct add_const_if_c
{
typedef std::conditional_t
<
IsConst,
Type const,
Type
> type;
};
namespace util
{
template <typename T>
using bare_type = geometry::detail::remove_cptrref<T>;
} // namespace util
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP