| 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 |
|
| 9 |
// <forward_list> |
| 10 |
|
| 11 |
// reference front(); |
| 12 |
// const_reference front() const; |
| 13 |
|
| 14 |
#include <forward_list> |
| 15 |
#include <cassert> |
| 16 |
#include <iterator> |
| 17 |
|
| 18 |
#include "test_macros.h" |
| 19 |
#include "min_allocator.h" |
| 20 |
|
| 21 |
int main(int, char**) |
| 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 |
return 0; |
| 63 |
} |