Home | History | Annotate | Download | only in back.insert.iter.op=
      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 // <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 
     22 template <class C>
     23 void
     24 test(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 
     32 class Copyable
     33 {
     34     int data_;
     35 public:
     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 
     43 int main()
     44 {
     45     test(std::vector<Copyable>());
     46 }
     47