blob: 80aadcb355a0b201bdc19e910705960f110730e1 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-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 Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
12// basic_string(basic_string&& str, const Allocator& alloc);
13
14#include <string>
15#include <cassert>
16
Howard Hinnant7609c9b2010-09-04 23:28:19 +000017#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant3e519522010-05-11 19:42:16 +000018
19#include "../test_allocator.h"
Howard Hinnanteec72182013-06-28 16:59:19 +000020#include "../min_allocator.h"
21
Howard Hinnant3e519522010-05-11 19:42:16 +000022
23template <class S>
24void
25test(S s0, const typename S::allocator_type& a)
26{
27 S s1 = s0;
28 S s2(std::move(s0), a);
29 assert(s2.__invariants());
30 assert(s0.__invariants());
31 assert(s2 == s1);
32 assert(s2.capacity() >= s2.size());
33 assert(s2.get_allocator() == a);
34}
35
Howard Hinnant7609c9b2010-09-04 23:28:19 +000036#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant3e519522010-05-11 19:42:16 +000037
38int main()
39{
Howard Hinnant7609c9b2010-09-04 23:28:19 +000040#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnanteec72182013-06-28 16:59:19 +000041 {
Howard Hinnant3e519522010-05-11 19:42:16 +000042 typedef test_allocator<char> A;
43 typedef std::basic_string<char, std::char_traits<char>, A> S;
44 test(S(), A(3));
45 test(S("1"), A(5));
46 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
Howard Hinnanteec72182013-06-28 16:59:19 +000047 }
48#if __cplusplus >= 201103L
49 {
50 typedef min_allocator<char> A;
51 typedef std::basic_string<char, std::char_traits<char>, A> S;
52 test(S(), A());
53 test(S("1"), A());
54 test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
55 }
56#endif
Howard Hinnant7609c9b2010-09-04 23:28:19 +000057#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant3e519522010-05-11 19:42:16 +000058}