traits.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright Matt Borland 2021 - 2023.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_NUMERIC_ODEINT_TOOLS_TRAITS
  6. #define BOOST_NUMERIC_ODEINT_TOOLS_TRAITS
  7. #include <type_traits>
  8. namespace boost {
  9. namespace numeric {
  10. namespace odeint {
  11. namespace detail {
  12. #define BOOST_NUMERIC_ODEINT_HAS_NAMED_TRAIT(trait, name) \
  13. template <typename T> \
  14. class trait \
  15. { \
  16. private: \
  17. using yes = char; \
  18. struct no { char x[2]; }; \
  19. \
  20. template <typename U> \
  21. static yes test(typename U::name* = nullptr); \
  22. \
  23. template <typename U> \
  24. static no test(...); \
  25. \
  26. public: \
  27. static constexpr bool value = (sizeof(test<T>(0)) == sizeof(char)); \
  28. };
  29. } //namespace detail
  30. } //namespace odeint
  31. } //namespace numeric
  32. } //namespace boost
  33. #endif //BOOST_NUMERIC_ODEINT_TOOLS_TRAITS