| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <iterator> |
| 10 | |
| 11 | // front_insert_iterator |
| 12 | |
| 13 | // front_insert_iterator<Cont>& |
| 14 | // operator=(const Cont::value_type& value); |
| 15 | |
| 16 | #include <cassert> |
| 17 | #include <iterator> |
| 18 | #include <list> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | #include "nasty_containers.h" |
| 22 | #include "test_constexpr_container.h" |
| 23 | |
| 24 | template <class C> |
| 25 | TEST_CONSTEXPR_CXX20 bool |
| 26 | test(C c) |
| 27 | { |
| 28 | const typename C::value_type v = typename C::value_type(); |
| 29 | std::front_insert_iterator<C> i(c); |
| 30 | i = v; |
| 31 | assert(c.front() == v); |
| 32 | return true; |
| 33 | } |
| 34 | |
| 35 | class Copyable |
| 36 | { |
| 37 | int data_; |
| 38 | public: |
| 39 | Copyable() : data_(0) {} |
| 40 | Copyable(const Copyable&) = default; |
| 41 | Copyable& operator=(const Copyable&) = default; |
| 42 | ~Copyable() {data_ = -1;} |
| 43 | |
| 44 | friend bool operator==(const Copyable& x, const Copyable& y) |
| 45 | {return x.data_ == y.data_;} |
| 46 | }; |
| 47 | |
| 48 | int main(int, char**) |
| 49 | { |
| 50 | test(std::list<Copyable>()); |
| 51 | test(nasty_list<Copyable>()); |
| 52 | #if TEST_STD_VER >= 20 |
| 53 | test(ConstexprFixedCapacityDeque<int, 10>()); |
| 54 | static_assert(test(ConstexprFixedCapacityDeque<int, 10>())); |
| 55 | #endif |
| 56 | return 0; |
| 57 | } |
| 58 | |