libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

move_noexcept.pass.cpp (1234B)


      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(basic_string&&)
     15 //        noexcept(is_nothrow_move_constructible<allocator_type>::value);
     16 
     17 // This tests a conforming extension
     18 
     19 #include <string>
     20 #include <cassert>
     21 
     22 #include "test_macros.h"
     23 #include "test_allocator.h"
     24 
     25 int main()
     26 {
     27     {
     28         typedef std::string C;
     29         static_assert(std::is_nothrow_move_constructible<C>::value, "");
     30     }
     31     {
     32         typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
     33         static_assert(std::is_nothrow_move_constructible<C>::value, "");
     34     }
     35     {
     36         typedef std::basic_string<char, std::char_traits<char>, limited_allocator<char, 10>> C;
     37 #if TEST_STD_VER <= 14
     38         static_assert(!std::is_nothrow_move_constructible<C>::value, "");
     39 #else
     40         static_assert( std::is_nothrow_move_constructible<C>::value, "");
     41 #endif
     42     }
     43 }