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> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 13 | // basic_string<charT,traits,Allocator> |
| 14 | // operator+(const basic_string<charT,traits,Allocator>& lhs, charT 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+(basic_string<charT,traits,Allocator>&& lhs, charT rhs); |
| 19 | |
| 20 | #include <string> |
| 21 | #include <cassert> |
| 22 | |
| 23 | template <class S> |
| 24 | void |
| 25 | test0(const S& lhs, typename S::value_type 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(S&& lhs, typename S::value_type rhs, const S& x) |
| 35 | { |
| 36 | assert(move(lhs) + 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(""), '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 Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 50 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 51 | |
| 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 Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 57 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | } |