1 // Copyright (c) Andrey Semashev 2017.
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)
6 // See http://www.boost.org/libs/config for most recent version.
8 // MACRO: BOOST_NO_CXX17_ITERATOR_TRAITS
9 // TITLE: C++17 std::iterator_traits
10 // DESCRIPTION: The compiler does not support SFINAE-friendly std::iterator_traits defined in C++17.
14 namespace boost_no_cxx17_iterator_traits {
18 typedef std::random_access_iterator_tag iterator_category;
19 typedef char value_type;
20 typedef std::ptrdiff_t difference_type;
21 typedef char* pointer;
22 typedef char& reference;
24 reference operator*()const;
25 iterator operator++();
28 struct non_iterator {};
30 template< typename T >
31 struct void_type { typedef void type; };
33 template< typename Traits, typename Void = void >
34 struct has_iterator_category
36 enum { value = false };
39 template< typename Traits >
40 struct has_iterator_category< Traits, typename void_type< typename Traits::iterator_category >::type >
42 enum { value = true };
47 static_assert(has_iterator_category< std::iterator_traits< boost_no_cxx17_iterator_traits::iterator > >::value, "has_iterator_category failed");
49 static_assert(!has_iterator_category< std::iterator_traits< boost_no_cxx17_iterator_traits::non_iterator > >::value, "has_iterator_category negative check failed");