blob: 904a0b89edd82fc54e02675a315fea0d8b6a0efa [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//
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<charT,traits,Allocator>&& str);
13
14#include <string>
15#include <cassert>
16
Howard Hinnant73d21a42010-09-04 23:28:19 +000017#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000018
19#include "../test_allocator.h"
20
21template <class S>
22void
23test(S s0)
24{
25 S s1 = s0;
26 S s2 = std::move(s0);
27 assert(s2.__invariants());
28 assert(s0.__invariants());
29 assert(s2 == s1);
30 assert(s2.capacity() >= s2.size());
31 assert(s2.get_allocator() == s1.get_allocator());
32}
33
Howard Hinnant73d21a42010-09-04 23:28:19 +000034#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000035
36int main()
37{
Howard Hinnant73d21a42010-09-04 23:28:19 +000038#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000039 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 Hinnant73d21a42010-09-04 23:28:19 +000044#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000045}