1*053d81ceSMarshall Clow //===----------------------------------------------------------------------===// 2*053d81ceSMarshall Clow // 3*053d81ceSMarshall Clow // The LLVM Compiler Infrastructure 4*053d81ceSMarshall Clow // 5*053d81ceSMarshall Clow // This file is dual licensed under the MIT and the University of Illinois Open 6*053d81ceSMarshall Clow // Source Licenses. See LICENSE.TXT for details. 7*053d81ceSMarshall Clow // 8*053d81ceSMarshall Clow //===----------------------------------------------------------------------===// 9*053d81ceSMarshall Clow 10*053d81ceSMarshall Clow 11*053d81ceSMarshall Clow // <string_view> 12*053d81ceSMarshall Clow 13*053d81ceSMarshall Clow // template<class Allocator> 14*053d81ceSMarshall Clow // basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept 15*053d81ceSMarshall Clow 16*053d81ceSMarshall Clow 17*053d81ceSMarshall Clow #include <string_view> 18*053d81ceSMarshall Clow #include <string> 19*053d81ceSMarshall Clow #include <cassert> 20*053d81ceSMarshall Clow 21*053d81ceSMarshall Clow #include "test_macros.h" 22*053d81ceSMarshall Clow 23*053d81ceSMarshall Clow struct dummy_char_traits : public std::char_traits<char> {}; 24*053d81ceSMarshall Clow 25*053d81ceSMarshall Clow template<typename CharT, typename Traits> 26*053d81ceSMarshall Clow void test ( const std::basic_string<CharT, Traits> &str ) { 27*053d81ceSMarshall Clow std::basic_string_view<CharT, Traits> sv1 ( str ); 28*053d81ceSMarshall Clow assert ( sv1.size() == str.size()); 29*053d81ceSMarshall Clow assert ( sv1.data() == str.data()); 30*053d81ceSMarshall Clow } 31*053d81ceSMarshall Clow 32*053d81ceSMarshall Clow int main () { 33*053d81ceSMarshall Clow 34*053d81ceSMarshall Clow test ( std::string("QBCDE") ); 35*053d81ceSMarshall Clow test ( std::string("") ); 36*053d81ceSMarshall Clow test ( std::string() ); 37*053d81ceSMarshall Clow 38*053d81ceSMarshall Clow test ( std::wstring(L"QBCDE") ); 39*053d81ceSMarshall Clow test ( std::wstring(L"") ); 40*053d81ceSMarshall Clow test ( std::wstring() ); 41*053d81ceSMarshall Clow 42*053d81ceSMarshall Clow #if TEST_STD_VER >= 11 43*053d81ceSMarshall Clow test ( std::u16string{u"QBCDE"} ); 44*053d81ceSMarshall Clow test ( std::u16string{u""} ); 45*053d81ceSMarshall Clow test ( std::u16string{} ); 46*053d81ceSMarshall Clow 47*053d81ceSMarshall Clow test ( std::u32string{U"QBCDE"} ); 48*053d81ceSMarshall Clow test ( std::u32string{U""} ); 49*053d81ceSMarshall Clow test ( std::u32string{} ); 50*053d81ceSMarshall Clow #endif 51*053d81ceSMarshall Clow 52*053d81ceSMarshall Clow test ( std::basic_string<char, dummy_char_traits>("QBCDE") ); 53*053d81ceSMarshall Clow test ( std::basic_string<char, dummy_char_traits>("") ); 54*053d81ceSMarshall Clow test ( std::basic_string<char, dummy_char_traits>() ); 55*053d81ceSMarshall Clow 56*053d81ceSMarshall Clow } 57