Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 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 Hinnant | 6e0a1f4 | 2010-08-22 00:47:54 +0000 | [diff] [blame] | 12 | // template<class charT, class traits, class Allocator> |
| 13 | // basic_string<charT,traits,Allocator> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 14 | // operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); |
| 15 | |
Howard Hinnant | 6e0a1f4 | 2010-08-22 00:47:54 +0000 | [diff] [blame] | 16 | // template<class charT, class traits, class Allocator> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 17 | // basic_string<charT,traits,Allocator>&& |
| 18 | // operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs); |
| 19 | |
| 20 | #include <string> |
| 21 | #include <cassert> |
| 22 | |
| 23 | template <class S> |
| 24 | void |
| 25 | test0(const typename S::value_type* lhs, const S& rhs, const S& x) |
| 26 | { |
| 27 | assert(lhs + rhs == x); |
| 28 | } |
| 29 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 30 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 31 | |
| 32 | template <class S> |
| 33 | void |
| 34 | test1(const typename S::value_type* lhs, S&& rhs, const S& x) |
| 35 | { |
| 36 | assert(lhs + move(rhs) == x); |
| 37 | } |
| 38 | |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 39 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 40 | |
| 41 | typedef std::string S; |
| 42 | |
| 43 | int 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 Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 62 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | |
| 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 Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 81 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 82 | } |