blob: d6cd5fa2fd4143305e7fb7410b8c3f3cc346e73c [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <string>
11
Howard Hinnant6e0a1f42010-08-22 00:47:54 +000012// template<class charT, class traits, class Allocator>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000013// basic_string<charT,traits,Allocator>
14// operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
15
Howard Hinnant6e0a1f42010-08-22 00:47:54 +000016// template<class charT, class traits, class Allocator>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000017// basic_string<charT,traits,Allocator>&&
18// operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs);
19
20#include <string>
21#include <cassert>
22
23template <class S>
24void
25test0(const S& lhs, typename S::value_type rhs, const S& x)
26{
27 assert(lhs + rhs == x);
28}
29
Howard Hinnant73d21a42010-09-04 23:28:19 +000030#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000031
32template <class S>
33void
34test1(S&& lhs, typename S::value_type rhs, const S& x)
35{
36 assert(move(lhs) + rhs == x);
37}
38
Howard Hinnant73d21a42010-09-04 23:28:19 +000039#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000040
41typedef std::string S;
42
43int main()
44{
45 test0(S(""), '1', S("1"));
46 test0(S("abcde"), '1', S("abcde1"));
47 test0(S("abcdefghij"), '1', S("abcdefghij1"));
48 test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
49
Howard Hinnant73d21a42010-09-04 23:28:19 +000050#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000051
52 test1(S(""), '1', S("1"));
53 test1(S("abcde"), '1', S("abcde1"));
54 test1(S("abcdefghij"), '1', S("abcdefghij1"));
55 test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
56
Howard Hinnant73d21a42010-09-04 23:28:19 +000057#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000058}