summaryrefslogtreecommitdiffstats
path: root/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
blob: d3f3ef27ccbb9c0cab0be0497c9c097e55274846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <forward_list>

// void clear();

#include <forward_list>
#include <cassert>

#include "../../../NotConstructible.h"

int main()
{
    {
        typedef NotConstructible T;
        typedef std::forward_list<T> C;
        C c;
        c.clear();
        assert(distance(c.begin(), c.end()) == 0);
    }
    {
        typedef int T;
        typedef std::forward_list<T> C;
        const T t[] = {0, 1, 2, 3, 4};
        C c(std::begin(t), std::end(t));

        c.clear();
        assert(distance(c.begin(), c.end()) == 0);

        c.clear();
        assert(distance(c.begin(), c.end()) == 0);
    }
}