is_const_iterable.hpp 1.3 KB

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