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