Hello Developers,
I would like to retrofit some type-traits in boost, but I have read https://pdimov.github.io/articles/phasing_out_cxx03.html. 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:
#ifndef BOOST_META_HPP
#define BOOST_META_HPP
#include
#if defined(__cpp_concepts)
#include <concepts>
#endif
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>;
...
#endif
} // boost::meta
#endif // BOOST_META_HPP
Then you could possibly map this in boost/type_traits.hpp to boost:: (if that makes sense):
#ifndef BOOST_TYPE_TRAITS_HPP
#define BOOST_TYPE_TRAITS_HPP
#include
remove boost implementations
namespace boost
{
using namespace boost::meta;
} // boost
#endif // BOOST_TYPE_TRAITS_HPP
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>;
#endif
} // boost::meta
and in this case add in boost/logic/tribool.hpp
namespace boost::meta
{
template <> struct is_logicboost::tribool : std::true_type{};
} // boost::meta
Or do you have a better idea?
regards
Gero