Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <set> |
| 11 | |
| 12 | // class set |
| 13 | |
| 14 | // pair<iterator, bool> insert(value_type&& v); |
| 15 | |
| 16 | #include <set> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "../../MoveOnly.h" |
| 20 | |
| 21 | int main() |
| 22 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 23 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 24 | { |
| 25 | typedef std::set<MoveOnly> M; |
| 26 | typedef std::pair<M::iterator, bool> R; |
| 27 | M m; |
| 28 | R r = m.insert(M::value_type(2)); |
| 29 | assert(r.second); |
| 30 | assert(r.first == m.begin()); |
| 31 | assert(m.size() == 1); |
| 32 | assert(*r.first == 2); |
| 33 | |
| 34 | r = m.insert(M::value_type(1)); |
| 35 | assert(r.second); |
| 36 | assert(r.first == m.begin()); |
| 37 | assert(m.size() == 2); |
| 38 | assert(*r.first == 1); |
| 39 | |
| 40 | r = m.insert(M::value_type(3)); |
| 41 | assert(r.second); |
| 42 | assert(r.first == prev(m.end())); |
| 43 | assert(m.size() == 3); |
| 44 | assert(*r.first == 3); |
| 45 | |
| 46 | r = m.insert(M::value_type(3)); |
| 47 | assert(!r.second); |
| 48 | assert(r.first == prev(m.end())); |
| 49 | assert(m.size() == 3); |
| 50 | assert(*r.first == 3); |
| 51 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 52 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 53 | } |