blob: ccfe50891c9de3d7b0aa25357d31257715976345 [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&& str, const Allocator& alloc);
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, 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 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}