blob: b94f189ecb4697f731069b9bc44f9d22bbf5c7a0 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// basic_string(basic_string<charT,traits,Allocator>&& str);
13
14#include <string>
15#include <cassert>
16
Dan Albert1d4a1ed2016-05-25 22:36:09 -070017#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
18
Marshall Clow1b921882013-12-03 00:18:10 +000019#include "test_allocator.h"
Marshall Clow061d0cc2013-11-26 20:58:02 +000020#include "min_allocator.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000021
22template <class S>
23void
24test(S s0)
25{
26 S s1 = s0;
27 S s2 = std::move(s0);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070028 assert(s2.__invariants());
29 assert(s0.__invariants());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000030 assert(s2 == s1);
31 assert(s2.capacity() >= s2.size());
32 assert(s2.get_allocator() == s1.get_allocator());
33}
34
Dan Albert1d4a1ed2016-05-25 22:36:09 -070035#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
36
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000037int main()
38{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070039#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant9dcdcde2013-06-28 16:59:19 +000040 {
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000041 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 Hinnant9dcdcde2013-06-28 16:59:19 +000046 }
Dan Albert1d4a1ed2016-05-25 22:36:09 -070047#if __cplusplus >= 201103L
Howard Hinnant9dcdcde2013-06-28 16:59:19 +000048 {
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 }
Dan Albert1d4a1ed2016-05-25 22:36:09 -070055#endif
56#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000057}