diff --git a/include/boost/numeric/odeint/tools/traits.hpp b/include/boost/numeric/odeint/tools/traits.hpp new file mode 100644 index 00000000..f321412c --- /dev/null +++ b/include/boost/numeric/odeint/tools/traits.hpp @@ -0,0 +1,39 @@ +// Copyright Matt Borland 2021 - 2023. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_NUMERIC_ODEINT_TOOLS_TRAITS +#define BOOST_NUMERIC_ODEINT_TOOLS_TRAITS + +#include + +namespace boost { +namespace numeric { +namespace odeint { +namespace detail { + +#define BOOST_NUMERIC_ODEINT_HAS_NAMED_TRAIT(trait, name) \ +template \ +class trait \ +{ \ +private: \ + using yes = char; \ + struct no { char x[2]; }; \ + \ + template \ + static yes test(typename U::name* = nullptr); \ + \ + template \ + static no test(...); \ + \ +public: \ + static constexpr bool value = (sizeof(test(0)) == sizeof(char)); \ +}; + +} //namespace detail +} //namespace odeint +} //namespace numeric +} //namespace boost + +#endif //BOOST_NUMERIC_ODEINT_TOOLS_TRAITS diff --git a/include/boost/numeric/odeint/util/detail/is_range.hpp b/include/boost/numeric/odeint/util/detail/is_range.hpp index 07676a87..b77ca595 100644 --- a/include/boost/numeric/odeint/util/detail/is_range.hpp +++ b/include/boost/numeric/odeint/util/detail/is_range.hpp @@ -28,25 +28,19 @@ #include #include #include -#include +#include namespace boost { namespace numeric { namespace odeint { +namespace detail { - -namespace range_detail -{ -BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator) - BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator) -} - -namespace detail -{ +BOOST_NUMERIC_ODEINT_HAS_NAMED_TRAIT(has_iterator, iterator); +BOOST_NUMERIC_ODEINT_HAS_NAMED_TRAIT(has_const_iterator, const_iterator); template< typename Range > -struct is_range : std::integral_constant::value && range_detail::has_const_iterator::value)> +struct is_range : std::integral_constant::value && has_const_iterator::value)> { };