• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // UNSUPPORTED: c++98, c++03
11 
12 // <string>
13 
14 // ~basic_string() // implied noexcept;
15 
16 #include <string>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 #include "test_allocator.h"
21 
22 template <class T>
23 struct some_alloc
24 {
25     typedef T value_type;
26     some_alloc(const some_alloc&);
27     ~some_alloc() noexcept(false);
28 };
29 
30 // Test that it's possible to take the address of basic_string's destructors
31 // by creating globals which will register their destructors with cxa_atexit.
32 std::string s;
33 std::wstring ws;
34 
main()35 int main()
36 {
37     {
38         typedef std::string C;
39         static_assert(std::is_nothrow_destructible<C>::value, "");
40     }
41     {
42         typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
43         static_assert(std::is_nothrow_destructible<C>::value, "");
44     }
45 #if defined(_LIBCPP_VERSION)
46     {
47         typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
48         static_assert(!std::is_nothrow_destructible<C>::value, "");
49     }
50 #endif // _LIBCPP_VERSION
51 }
52