Is std :: string not a persistent wrapper, assignable or comparable?

I played with type_traits, and I discovered this strange property std::string:

$ cat a.cpp
#include <string>
#include <type_traits>

static_assert(std::is_nothrow_move_assignable<std::string>::value, "???");
static_assert(noexcept(std::declval<std::string>() == std::declval<std::string>()), "???");
$ g++ -std=c++14 a.cpp
a.cpp:4:1: error: static assertion failed: ???
 static_assert(std::is_nothrow_move_assignable<std::string>::value, "???");
 ^
a.cpp:5:1: error: static assertion failed: ???
 static_assert(noexcept(std::declval<std::string>() == std::declval<std::string>()), "???");
 ^
$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609

However, cppreference asserts the move assignment operator and comparison operators are marked noexcept.

Am I doing something wrong? This is mistake?

+4
source share
1 answer

However, cppreference states that the move assignment operator and comparison operators are marked noexcept.

, ++ 11 , noexcept, ( , ). . DR 2063.

, , GCC, noexcept. GCC 6.1 (. PR 58265) gcc-5, GCC 5.x . 5.5, .

+3

Source: https://habr.com/ru/post/1654590/


All Articles