Home | History | Annotate | Download | only in string.cons
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. 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 
     17 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     18 
     19 #include "test_allocator.h"
     20 #include "min_allocator.h"
     21 
     22 
     23 template <class S>
     24 void
     25 test(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 
     36 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     37 
     38 int main()
     39 {
     40 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     41     {
     42     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));
     47     }
     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
     57 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     58 }
     59