1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03
10 
11 // ITER_TRAITS(I)
12 
13 // For a type I, let ITER_TRAITS(I) denote the type I if iterator_traits<I> names
14 // a specialization generated from the primary template. Otherwise,
15 // ITER_TRAITS(I) denotes iterator_traits<I>.
16 
17 #include <iterator>
18 #include <type_traits>
19 
20 #include "test_iterators.h"
21 
22 struct A : random_access_iterator<int*> {};
23 struct B : random_access_iterator<int*> {};
24 struct C : random_access_iterator<int*> {};
25 struct D : random_access_iterator<int*> {};
26 template<> struct std::iterator_traits<B> {};
27 template<> struct std::iterator_traits<C> : std::iterator_traits<A> {};
28 template<> struct std::iterator_traits<D> : std::iterator_traits<int*> {};
29 
30 static_assert(std::is_same<std::_ITER_TRAITS<int*>, std::iterator_traits<int*>>::value, "");
31 static_assert(std::is_same<std::_ITER_TRAITS<A>, A>::value, "");
32 static_assert(std::is_same<std::_ITER_TRAITS<B>, std::iterator_traits<B>>::value, "");
33 static_assert(std::is_same<std::_ITER_TRAITS<C>, std::iterator_traits<C>>::value, "");
34 static_assert(std::is_same<std::_ITER_TRAITS<D>, std::iterator_traits<D>>::value, "");
35