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