lv_value.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <iterator>
11
12// front_insert_iterator
13
14// front_insert_iterator<Cont>&
15//   operator=(const Cont::value_type& value);
16
17#include <iterator>
18#include <list>
19#include <cassert>
20
21template <class C>
22void
23test(C c)
24{
25    const typename C::value_type v = typename C::value_type();
26    std::front_insert_iterator<C> i(c);
27    i = v;
28    assert(c.front() == v);
29}
30
31class Copyable
32{
33    int data_;
34public:
35    Copyable() : data_(0) {}
36    ~Copyable() {data_ = -1;}
37
38    friend bool operator==(const Copyable& x, const Copyable& y)
39        {return x.data_ == y.data_;}
40};
41
42int main()
43{
44    test(std::list<Copyable>());
45}
46