Home | History | Annotate | Download | only in forwardlist.access
      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 // <forward_list>
     11 
     12 // reference       front();
     13 // const_reference front() const;
     14 
     15 #include <forward_list>
     16 #include <cassert>
     17 #include <iterator>
     18 
     19 #include "min_allocator.h"
     20 
     21 int main()
     22 {
     23     {
     24         typedef int T;
     25         typedef std::forward_list<T> C;
     26         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     27         C c(std::begin(t), std::end(t));
     28         assert(c.front() == 0);
     29         c.front() = 10;
     30         assert(c.front() == 10);
     31         assert(*c.begin() == 10);
     32     }
     33     {
     34         typedef int T;
     35         typedef std::forward_list<T> C;
     36         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     37         const C c(std::begin(t), std::end(t));
     38         assert(c.front() == 0);
     39         assert(*c.begin() == 0);
     40     }
     41 #if TEST_STD_VER >= 11
     42     {
     43         typedef int T;
     44         typedef std::forward_list<T, min_allocator<T>> C;
     45         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     46         C c(std::begin(t), std::end(t));
     47         assert(c.front() == 0);
     48         c.front() = 10;
     49         assert(c.front() == 10);
     50         assert(*c.begin() == 10);
     51     }
     52     {
     53         typedef int T;
     54         typedef std::forward_list<T, min_allocator<T>> C;
     55         const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
     56         const C c(std::begin(t), std::end(t));
     57         assert(c.front() == 0);
     58         assert(*c.begin() == 0);
     59     }
     60 #endif
     61 }
     62