Dan Albert | 287553d | 2017-02-16 10:47:51 -0800 | [diff] [blame] | 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 | // 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 | #include "nasty_containers.hpp" |
| 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::front_insert_iterator<C> i(c); |
| 28 | i = v; |
| 29 | assert(c.front() == 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::list<Copyable>()); |
| 46 | test(nasty_list<Copyable>()); |
| 47 | } |