blob: c9973a4f443373d4da9b8c566deabe91fa7a81ab [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>
13// basic_string<charT,traits,Allocator>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000014// operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& 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+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs);
19
20#include <string>
21#include <cassert>
22
23template <class S>
24void
25test0(const typename S::value_type* lhs, const S& 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(const typename S::value_type* lhs, S&& rhs, const S& x)
35{
36 assert(lhs + move(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(""), S(""));
46 test0("", S("12345"), S("12345"));
47 test0("", S("1234567890"), S("1234567890"));
48 test0("", S("12345678901234567890"), S("12345678901234567890"));
49 test0("abcde", S(""), S("abcde"));
50 test0("abcde", S("12345"), S("abcde12345"));
51 test0("abcde", S("1234567890"), S("abcde1234567890"));
52 test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
53 test0("abcdefghij", S(""), S("abcdefghij"));
54 test0("abcdefghij", S("12345"), S("abcdefghij12345"));
55 test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
56 test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
57 test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
58 test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
59 test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
60 test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
61
Howard Hinnant73d21a42010-09-04 23:28:19 +000062#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000063
64 test1("", S(""), S(""));
65 test1("", S("12345"), S("12345"));
66 test1("", S("1234567890"), S("1234567890"));
67 test1("", S("12345678901234567890"), S("12345678901234567890"));
68 test1("abcde", S(""), S("abcde"));
69 test1("abcde", S("12345"), S("abcde12345"));
70 test1("abcde", S("1234567890"), S("abcde1234567890"));
71 test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
72 test1("abcdefghij", S(""), S("abcdefghij"));
73 test1("abcdefghij", S("12345"), S("abcdefghij12345"));
74 test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
75 test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
76 test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
77 test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
78 test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
79 test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
80
Howard Hinnant73d21a42010-09-04 23:28:19 +000081#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000082}