Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <string> |
| 11 | |
| 12 | // basic_string(basic_string<charT,traits,Allocator>&& str); |
| 13 | |
| 14 | #include <string> |
| 15 | #include <cassert> |
| 16 | |
Howard Hinnant | 7609c9b | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 17 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 18 | |
| 19 | #include "../test_allocator.h" |
Marshall Clow | e34f6f6 | 2013-11-26 20:58:02 +0000 | [diff] [blame^] | 20 | #include "min_allocator.h" |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
| 22 | template <class S> |
| 23 | void |
| 24 | test(S s0) |
| 25 | { |
| 26 | S s1 = s0; |
| 27 | S s2 = std::move(s0); |
| 28 | assert(s2.__invariants()); |
| 29 | assert(s0.__invariants()); |
| 30 | assert(s2 == s1); |
| 31 | assert(s2.capacity() >= s2.size()); |
| 32 | assert(s2.get_allocator() == s1.get_allocator()); |
| 33 | } |
| 34 | |
Howard Hinnant | 7609c9b | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 35 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 36 | |
| 37 | int main() |
| 38 | { |
Howard Hinnant | 7609c9b | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 39 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 40 | { |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | typedef test_allocator<char> A; |
| 42 | typedef std::basic_string<char, std::char_traits<char>, A> S; |
| 43 | test(S(A(3))); |
| 44 | test(S("1", A(5))); |
| 45 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7))); |
Howard Hinnant | eec7218 | 2013-06-28 16:59:19 +0000 | [diff] [blame] | 46 | } |
| 47 | #if __cplusplus >= 201103L |
| 48 | { |
| 49 | typedef min_allocator<char> A; |
| 50 | typedef std::basic_string<char, std::char_traits<char>, A> S; |
| 51 | test(S(A{})); |
| 52 | test(S("1", A())); |
| 53 | test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A())); |
| 54 | } |
| 55 | #endif |
Howard Hinnant | 7609c9b | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 56 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 57 | } |