Eric Fiselier | dba23b4 | 2016-05-07 03:09:55 +0000 | [diff] [blame] | 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 | // UNSUPPORTED: c++98, c++03 |
| 12 | |
| 13 | // <experimental/string> |
| 14 | |
| 15 | // namespace std { namespace experimental { namespace pmr { |
| 16 | // template <class Char, class Traits = ...> |
| 17 | // using basic_string = |
| 18 | // ::std::basic_string<Char, Traits, polymorphic_allocator<Char>> |
| 19 | // |
| 20 | // typedef ... string |
| 21 | // typedef ... u16string |
| 22 | // typedef ... u32string |
| 23 | // typedef ... wstring |
| 24 | // |
| 25 | // }}} // namespace std::experimental::pmr |
| 26 | |
| 27 | #include <experimental/string> |
| 28 | #include <experimental/memory_resource> |
| 29 | #include <type_traits> |
| 30 | #include <cassert> |
| 31 | |
| 32 | #include "constexpr_char_traits.hpp" |
| 33 | |
| 34 | namespace pmr = std::experimental::pmr; |
| 35 | |
| 36 | template <class Char, class PmrTypedef> |
| 37 | void test_string_typedef() { |
| 38 | using StdStr = std::basic_string<Char, std::char_traits<Char>, |
| 39 | pmr::polymorphic_allocator<Char>>; |
| 40 | using PmrStr = pmr::basic_string<Char>; |
| 41 | static_assert(std::is_same<StdStr, PmrStr>::value, ""); |
| 42 | static_assert(std::is_same<PmrStr, PmrTypedef>::value, ""); |
| 43 | } |
| 44 | |
| 45 | template <class Char, class Traits> |
| 46 | void test_basic_string_alias() { |
| 47 | using StdStr = std::basic_string<Char, Traits, |
| 48 | pmr::polymorphic_allocator<Char>>; |
| 49 | using PmrStr = pmr::basic_string<Char, Traits>; |
| 50 | static_assert(std::is_same<StdStr, PmrStr>::value, ""); |
| 51 | } |
| 52 | |
| 53 | int main() |
| 54 | { |
| 55 | { |
| 56 | test_string_typedef<char, pmr::string>(); |
| 57 | test_string_typedef<wchar_t, pmr::wstring>(); |
| 58 | test_string_typedef<char16_t, pmr::u16string>(); |
| 59 | test_string_typedef<char32_t, pmr::u32string>(); |
| 60 | } |
| 61 | { |
| 62 | test_basic_string_alias<char, constexpr_char_traits<char>>(); |
| 63 | test_basic_string_alias<wchar_t, constexpr_char_traits<wchar_t>>(); |
| 64 | test_basic_string_alias<char16_t, constexpr_char_traits<char16_t>>(); |
| 65 | test_basic_string_alias<char32_t, constexpr_char_traits<char32_t>>(); |
| 66 | } |
| 67 | { |
| 68 | // Check that std::basic_string has been included and is complete. |
| 69 | pmr::string s; |
| 70 | assert(s.get_allocator().resource() == pmr::get_default_resource()); |
| 71 | } |
| 72 | } |