2
0
mirror of https://github.com/boostorg/odeint.git synced 2026-01-19 04:22:12 +00:00

Define our own replacement for BOOST_MPL_HAS_XXX_TRAIT

This commit is contained in:
Matt Borland
2023-12-20 17:25:52 +01:00
parent 0fc091f92f
commit d22fbb4ee7
2 changed files with 44 additions and 11 deletions

View File

@@ -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 <type_traits>
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
#define BOOST_NUMERIC_ODEINT_HAS_NAMED_TRAIT(trait, name) \
template <typename T> \
class trait \
{ \
private: \
using yes = char; \
struct no { char x[2]; }; \
\
template <typename U> \
static yes test(typename U::name* = nullptr); \
\
template <typename U> \
static no test(...); \
\
public: \
static constexpr bool value = (sizeof(test<T>(0)) == sizeof(char)); \
};
} //namespace detail
} //namespace odeint
} //namespace numeric
} //namespace boost
#endif //BOOST_NUMERIC_ODEINT_TOOLS_TRAITS

View File

@@ -28,25 +28,19 @@
#include <cstddef>
#include <type_traits>
#include <boost/range/config.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/numeric/odeint/tools/traits.hpp>
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<bool, (range_detail::has_iterator<Range>::value && range_detail::has_const_iterator<Range>::value)>
struct is_range : std::integral_constant<bool, (has_iterator<Range>::value && has_const_iterator<Range>::value)>
{
};