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