pointer.pass.cpp 1.2 KB

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