header_string_synop.pass.cpp (2434B)
1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 // REQUIRES: c++experimental 12 // UNSUPPORTED: c++98, c++03 13 14 // <experimental/string> 15 16 // namespace std { namespace experimental { namespace pmr { 17 // template <class Char, class Traits = ...> 18 // using basic_string = 19 // ::std::basic_string<Char, Traits, polymorphic_allocator<Char>> 20 // 21 // typedef ... string 22 // typedef ... u16string 23 // typedef ... u32string 24 // typedef ... wstring 25 // 26 // }}} // namespace std::experimental::pmr 27 28 #include <experimental/string> 29 #include <experimental/memory_resource> 30 #include <type_traits> 31 #include <cassert> 32 33 #include "constexpr_char_traits.hpp" 34 35 namespace pmr = std::experimental::pmr; 36 37 template <class Char, class PmrTypedef> 38 void test_string_typedef() { 39 using StdStr = std::basic_string<Char, std::char_traits<Char>, 40 pmr::polymorphic_allocator<Char>>; 41 using PmrStr = pmr::basic_string<Char>; 42 static_assert(std::is_same<StdStr, PmrStr>::value, ""); 43 static_assert(std::is_same<PmrStr, PmrTypedef>::value, ""); 44 } 45 46 template <class Char, class Traits> 47 void test_basic_string_alias() { 48 using StdStr = std::basic_string<Char, Traits, 49 pmr::polymorphic_allocator<Char>>; 50 using PmrStr = pmr::basic_string<Char, Traits>; 51 static_assert(std::is_same<StdStr, PmrStr>::value, ""); 52 } 53 54 int main() 55 { 56 { 57 test_string_typedef<char, pmr::string>(); 58 test_string_typedef<wchar_t, pmr::wstring>(); 59 test_string_typedef<char16_t, pmr::u16string>(); 60 test_string_typedef<char32_t, pmr::u32string>(); 61 } 62 { 63 test_basic_string_alias<char, constexpr_char_traits<char>>(); 64 test_basic_string_alias<wchar_t, constexpr_char_traits<wchar_t>>(); 65 test_basic_string_alias<char16_t, constexpr_char_traits<char16_t>>(); 66 test_basic_string_alias<char32_t, constexpr_char_traits<char32_t>>(); 67 } 68 { 69 // Check that std::basic_string has been included and is complete. 70 pmr::string s; 71 assert(s.get_allocator().resource() == pmr::get_default_resource()); 72 } 73 }