is_const_iterable.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // (C) Copyright John Maddock 2018.
  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_MATH_TOOLS_IS_CONST_ITERABLE_HPP
  6. #define BOOST_MATH_TOOLS_IS_CONST_ITERABLE_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/math/tools/cxx03_warn.hpp>
  9. #if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_SFINAE_EXPR)
  10. #define BOOST_MATH_HAS_IS_CONST_ITERABLE
  11. #include <boost/type_traits/is_detected.hpp>
  12. #include <utility>
  13. namespace boost {
  14. namespace math {
  15. namespace tools {
  16. namespace detail {
  17. template<class T>
  18. using begin_t = decltype(std::declval<const T&>().begin());
  19. template<class T>
  20. using end_t = decltype(std::declval<const T&>().end());
  21. template<class T>
  22. using const_iterator_t = typename T::const_iterator;
  23. template <class T>
  24. struct is_const_iterable
  25. : public boost::integral_constant<bool,
  26. boost::is_detected<begin_t, T>::value
  27. && boost::is_detected<end_t, T>::value
  28. && boost::is_detected<const_iterator_t, T>::value
  29. > {};
  30. } } } }
  31. #endif
  32. #endif // BOOST_MATH_TOOLS_IS_CONST_ITERABLE_HPP