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