lv_value.pass.cpp revision 712522cfd8f61321b4f197ec0de02b0146afb5a5
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// back_insert_iterator
13
14// requires CopyConstructible<Cont::value_type>
15//   back_insert_iterator<Cont>&
16//   operator=(const Cont::value_type& value);
17
18#include <iterator>
19#include <vector>
20#include <cassert>
21
22template <class C>
23void
24test(C c)
25{
26    const typename C::value_type v = typename C::value_type();
27    std::back_insert_iterator<C> i(c);
28    i = v;
29    assert(c.back() == v);
30}
31
32class Copyable
33{
34    int data_;
35public:
36    Copyable() : data_(0) {}
37    ~Copyable() {data_ = -1;}
38
39    friend bool operator==(const Copyable& x, const Copyable& y)
40        {return x.data_ == y.data_;}
41};
42
43int main()
44{
45    test(std::vector<Copyable>());
46}
47