begin-end.fail.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include "test_macros.h"
  10. #if TEST_STD_VER < 11
  11. #error
  12. #else
  13. // <iterator>
  14. // template <class C> auto begin(C& c) -> decltype(c.begin());
  15. // template <class C> auto begin(const C& c) -> decltype(c.begin());
  16. // template <class C> auto end(C& c) -> decltype(c.end());
  17. // template <class C> auto end(const C& c) -> decltype(c.end());
  18. // template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il);
  19. // template <class E> reverse_iterator<const E*> rend(initializer_list<E> il);
  20. #include <iterator>
  21. #include <cassert>
  22. namespace Foo {
  23. struct FakeContainer {};
  24. typedef int FakeIter;
  25. FakeIter begin(const FakeContainer &) { return 1; }
  26. FakeIter end (const FakeContainer &) { return 2; }
  27. FakeIter rbegin(const FakeContainer &) { return 3; }
  28. FakeIter rend (const FakeContainer &) { return 4; }
  29. FakeIter cbegin(const FakeContainer &) { return 11; }
  30. FakeIter cend (const FakeContainer &) { return 12; }
  31. FakeIter crbegin(const FakeContainer &) { return 13; }
  32. FakeIter crend (const FakeContainer &) { return 14; }
  33. }
  34. int main(){
  35. // Bug #28927 - shouldn't find these via ADL
  36. (void) std::cbegin (Foo::FakeContainer());
  37. (void) std::cend (Foo::FakeContainer());
  38. (void) std::crbegin(Foo::FakeContainer());
  39. (void) std::crend (Foo::FakeContainer());
  40. }
  41. #endif