empty.pass.cpp 949 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 NotAnIterator>
  10. // struct iterator_traits
  11. // {
  12. // };
  13. #include <iterator>
  14. #include "test_macros.h"
  15. struct not_an_iterator
  16. {
  17. };
  18. template <class T>
  19. struct has_value_type
  20. {
  21. private:
  22. struct two {char lx; char lxx;};
  23. template <class U> static two test(...);
  24. template <class U> static char test(typename U::value_type* = 0);
  25. public:
  26. static const bool value = sizeof(test<T>(0)) == 1;
  27. };
  28. int main(int, char**)
  29. {
  30. typedef std::iterator_traits<not_an_iterator> It;
  31. static_assert(!(has_value_type<It>::value), "");
  32. return 0;
  33. }