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 // template<class charT, class traits, class Allocator>
13 //   basic_string<charT,traits,Allocator>
14 //   operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
15 
16 // template<class charT, class traits, class Allocator>
17 //   basic_string<charT,traits,Allocator>&&
18 //   operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs);
19 
20 #include <string>
21 #include <cassert>
22 
23 #include "min_allocator.h"
24 
25 template <class S>
26 void
27 test0(typename S::value_type lhs, const S& rhs, const S& x)
28 {
29     assert(lhs + rhs == x);
30 }
31 
32 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
33 
34 template <class S>
35 void
36 test1(typename S::value_type lhs, S&& rhs, const S& x)
37 {
38     assert(lhs + move(rhs) == x);
39 }
40 
41 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
42 
43 int main()
44 {
45     {
46     typedef std::string S;
47     test0('a', S(""), S("a"));
48     test0('a', S("12345"), S("a12345"));
49     test0('a', S("1234567890"), S("a1234567890"));
50     test0('a', S("12345678901234567890"), S("a12345678901234567890"));
51 
52 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
53 
54     test1('a', S(""), S("a"));
55     test1('a', S("12345"), S("a12345"));
56     test1('a', S("1234567890"), S("a1234567890"));
57     test1('a', S("12345678901234567890"), S("a12345678901234567890"));
58 
59 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
60     }
61 #if __cplusplus >= 201103L
62     {
63     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
64     test0('a', S(""), S("a"));
65     test0('a', S("12345"), S("a12345"));
66     test0('a', S("1234567890"), S("a1234567890"));
67     test0('a', S("12345678901234567890"), S("a12345678901234567890"));
68 
69 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
70 
71     test1('a', S(""), S("a"));
72     test1('a', S("12345"), S("a12345"));
73     test1('a', S("1234567890"), S("a1234567890"));
74     test1('a', S("12345678901234567890"), S("a12345678901234567890"));
75 
76 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
77     }
78 #endif
79 }
80