]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/config/test/boost_no_cxx17_iterator_traits.ipp
bump version to 18.2.4-pve3
[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 {
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;
23
24 reference operator*()const;
25 iterator operator++();
26 };
27
28 struct non_iterator {};
29
30 template< typename T >
31 struct void_type { typedef void type; };
32
33 template< typename Traits, typename Void = void >
34 struct has_iterator_category
35 {
36 enum { value = false };
37 };
38
39 template< typename Traits >
40 struct has_iterator_category< Traits, typename void_type< typename Traits::iterator_category >::type >
41 {
42 enum { value = true };
43 };
44
45 int test()
46 {
47 static_assert(has_iterator_category< std::iterator_traits< boost_no_cxx17_iterator_traits::iterator > >::value, "has_iterator_category failed");
48
49 static_assert(!has_iterator_category< std::iterator_traits< boost_no_cxx17_iterator_traits::non_iterator > >::value, "has_iterator_category negative check failed");
50
51 return 0;
52 }
53
54 }