]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/config/test/boost_no_cxx17_iterator_traits.ipp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / config / test / boost_no_cxx17_iterator_traits.ipp
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)
5
6 // See http://www.boost.org/libs/config for most recent version.
7
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.
11
12 #include <iterator>
13
14 namespace boost_no_cxx17_iterator_traits {
15
16 struct iterator :
17 public std::iterator< std::random_access_iterator_tag, char >
18 {
19 };
20
21 struct non_iterator {};
22
23 template< typename T >
24 struct void_type { typedef void type; };
25
26 template< typename Traits, typename Void = void >
27 struct has_iterator_category
28 {
29 enum { value = false };
30 };
31
32 template< typename Traits >
33 struct has_iterator_category< Traits, typename void_type< typename Traits::iterator_category >::type >
34 {
35 enum { value = true };
36 };
37
38 int test()
39 {
40 if (!has_iterator_category< std::iterator_traits< boost_no_cxx17_iterator_traits::iterator > >::value)
41 return 1;
42
43 if (has_iterator_category< std::iterator_traits< boost_no_cxx17_iterator_traits::non_iterator > >::value)
44 return 2;
45
46 return 0;
47 }
48
49 }