I am writing code in C ++ that uses std::unique_ptr u to process the std::string resource, and I want to dereference u so that I can pass std::string to the constructor call std::string :
std::string* copy = new std::string( );
I know that the copy constructor new or std::string can reset, but that is not my point here. I'm just wondering if dereferencing u already throw an exception. It is strange to me that operator* not marked with noexcept , and the std::unique_ptr get method is actually marked with noexcept . In other words:
*( u.get() )
is noexcept in general as well
*u
not. Is this a flaw in the standard? I do not understand why there may be a difference. Any ideas?
c ++ c ++ 11 unique-ptr
sperber
source share