Boost logo

Boost :

From: Gero Peterhoff (g.peterhoff_at_[hidden])
Date: 2020-09-12 12:47:20

Hello Developers,
I would like to retrofit some type-traits in boost, but I have read Now I don't know how to do it best, as the boost-type-traits may be removed.
Would the following procedure make sense? We get the std-traits and concepts in a namespace boost::meta, eg file boost/type_traits/meta.hpp:


#include <type_traits>

#if defined(__cpp_concepts)
#include <concepts>

namespace boost::meta
template <typename Type> using is_integral = std::is_integral<Type>;
template <typename Type> inline constexpr bool is_integral_v = std::is_integral_v<Type>;

template <typename Type> using is_pointer = std::is_pointer<Type>;
template <typename Type> inline constexpr bool is_pointer_v = std::is_pointer_v<Type>;

... all other

#if defined(__cpp_concepts)
template <typename Type> concept integral = std::integral<Type>;
template <typename Type> concept pointer = is_pointer_v<Type>;
} // boost::meta

#endif // BOOST_META_HPP

Then you could possibly map this in boost/type_traits.hpp to boost:: (if that makes sense):


#include <boost/type_traits/meta.hpp>

remove boost implementations

namespace boost
using namespace boost::meta;
} // boost


In this way, new traits can be added in boost/type_traits/meta.hpp that are based on the std-traits, e.g. is_logic
namespace boost::meta
template <typename Type> struct is_logic : std::false_type{};
template <typename Type> inline constexpr bool is_logic_v = is_logic<Type>::value;
template <> struct is_logic<bool> : std::true_type{};

#if defined(__cpp_concepts)
template <typename Type> concept logic = is_logic_v<Type>;
} // boost::meta

and in this case add in boost/logic/tribool.hpp
namespace boost::meta
template <> struct is_logic<boost::tribool> : std::true_type{};
} // boost::meta

Or do you have a better idea?


Boost list run by bdawes at, gregod at, cpdaniel at, john at