pointer_to.pass.cpp 831 B

123456789101112131415161718192021222324252627282930313233
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <memory>
  10. // template <class T>
  11. // struct pointer_traits<T*>
  12. // {
  13. // static pointer pointer_to(<details>);
  14. // ...
  15. // };
  16. #include <memory>
  17. #include <cassert>
  18. int main()
  19. {
  20. {
  21. int i = 0;
  22. static_assert((std::is_same<int *, decltype(std::pointer_traits<int*>::pointer_to(i))>::value), "");
  23. int* a = std::pointer_traits<int*>::pointer_to(i);
  24. assert(a == &i);
  25. }
  26. {
  27. (std::pointer_traits<void*>::element_type)0;
  28. }
  29. }