libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

begin-end.fail.cpp (1754B)


      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 
     32     FakeIter begin(const FakeContainer &)   { return 1; }
     33     FakeIter end  (const FakeContainer &)   { return 2; }
     34     FakeIter rbegin(const FakeContainer &)  { return 3; }
     35     FakeIter rend  (const FakeContainer &)  { return 4; }
     36 
     37     FakeIter cbegin(const FakeContainer &)  { return 11; }
     38     FakeIter cend  (const FakeContainer &)  { return 12; }
     39     FakeIter crbegin(const FakeContainer &) { return 13; }
     40     FakeIter crend  (const FakeContainer &) { return 14; }
     41 }
     42 
     43 
     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