blob: af117103d82762b03c9cdf0cad31b3ec67d62fe4 [file] [log] [blame]
Howard Hinnant53f7d4c2011-06-03 18:40:47 +00001//===----------------------------------------------------------------------===//
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// basic_string()
13// noexcept(is_nothrow_default_constructible<allocator_type>::value);
14
15// This tests a conforming extension
16
17#include <string>
18#include <cassert>
19
Marshall Clow7b193f72015-06-03 19:56:43 +000020#include "test_macros.h"
Marshall Clow1b921882013-12-03 00:18:10 +000021#include "test_allocator.h"
Howard Hinnant53f7d4c2011-06-03 18:40:47 +000022
23template <class T>
24struct some_alloc
25{
26 typedef T value_type;
27 some_alloc(const some_alloc&);
28};
29
30int main()
31{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070032#if __has_feature(cxx_noexcept)
Howard Hinnant53f7d4c2011-06-03 18:40:47 +000033 {
34 typedef std::string C;
35 static_assert(std::is_nothrow_default_constructible<C>::value, "");
36 }
37 {
38 typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
39 static_assert(std::is_nothrow_default_constructible<C>::value, "");
40 }
41 {
42 typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
43 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
Howard Hinnant53f7d4c2011-06-03 18:40:47 +000044 }
Dan Albert1d4a1ed2016-05-25 22:36:09 -070045#endif
Howard Hinnant53f7d4c2011-06-03 18:40:47 +000046}