]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / containers / sequences / forwardlist / forwardlist.modifiers / emplace_front.pass.cpp
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 // UNSUPPORTED: c++98, c++03
11
12 // <forward_list>
13
14 // template <class... Args> reference emplace_front(Args&&... args);
15
16 #include <forward_list>
17 #include <cassert>
18
19 #include "../../../Emplaceable.h"
20 #include "min_allocator.h"
21
22 int main()
23 {
24     {
25         typedef Emplaceable T;
26         typedef std::forward_list<T> C;
27         C c;
28         T& r1 = c.emplace_front();
29         assert(c.front() == Emplaceable());
30         assert(&r1 == &c.front());
31         assert(distance(c.begin(), c.end()) == 1);
32         T& r2 = c.emplace_front(1, 2.5);
33         assert(c.front() == Emplaceable(1, 2.5));
34         assert(&r2 == &c.front());
35         assert(*next(c.begin()) == Emplaceable());
36         assert(distance(c.begin(), c.end()) == 2);
37     }
38     {
39         typedef Emplaceable T;
40         typedef std::forward_list<T, min_allocator<T>> C;
41         C c;
42         T& r1 = c.emplace_front();
43         assert(c.front() == Emplaceable());
44         assert(&r1 == &c.front());
45         assert(distance(c.begin(), c.end()) == 1);
46         T& r2 = c.emplace_front(1, 2.5);
47         assert(c.front() == Emplaceable(1, 2.5));
48         assert(&r2 == &c.front());
49         assert(*next(c.begin()) == Emplaceable());
50         assert(distance(c.begin(), c.end()) == 2);
51     }
52 }