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 | // <string> |
| 11 | |
| 12 | // basic_string(basic_string&& str, const Allocator& alloc); |
| 13 | |
| 14 | #include <string> |
| 15 | #include <cassert> |
| 16 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 17 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 18 | |
| 19 | #include "../test_allocator.h" |
| 20 | |
| 21 | template <class S> |
| 22 | void |
| 23 | test(S s0, const typename S::allocator_type& a) |
| 24 | { |
| 25 | S s1 = s0; |
| 26 | S s2(std::move(s0), a); |
| 27 | assert(s2.__invariants()); |
| 28 | assert(s0.__invariants()); |
| 29 | assert(s2 == s1); |
| 30 | assert(s2.capacity() >= s2.size()); |
| 31 | assert(s2.get_allocator() == a); |
| 32 | } |
| 33 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 34 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 35 | |
| 36 | int main() |
| 37 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 38 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 39 | typedef test_allocator<char> A; |
| 40 | typedef std::basic_string<char, std::char_traits<char>, A> S; |
| 41 | test(S(), A(3)); |
| 42 | test(S("1"), A(5)); |
| 43 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7)); |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 44 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | } |