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 // <iterator> 10 11 // template<class T> 12 // struct iterator_traits<T*> 13 // { 14 // typedef ptrdiff_t difference_type; 15 // typedef T value_type; 16 // typedef T* pointer; 17 // typedef T& reference; 18 // typedef random_access_iterator_tag iterator_category; 19 // }; 20 21 #include <iterator> 22 #include <type_traits> 23 24 #include "test_macros.h" 25 26 struct A {}; 27 28 int main(int, char**) 29 { 30 typedef std::iterator_traits<A*> It; 31 static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), ""); 32 static_assert((std::is_same<It::value_type, A>::value), ""); 33 static_assert((std::is_same<It::pointer, A*>::value), ""); 34 static_assert((std::is_same<It::reference, A&>::value), ""); 35 static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), ""); 36 37 return 0; 38 } 39