#include <iostream> #include <type_traits> using namespace std; struct A { }; //simple structure struct B //structure with copy assingment operator { B& operator= (const B&) {return *this;} }; struct C //structure with exception { C& operator= (const C&) noexcept {return *this;} }; int main() { cout << boolalpha; cout << "is_nothrow_copy_assignable:" <<endl<<endl; cout << "int: " << std::is_nothrow_copy_assignable<int>::value << std::endl; cout << "A: " << std::is_nothrow_copy_assignable<A>::value << std::endl; cout << "B: " << std::is_nothrow_copy_assignable<B>::value << std::endl; cout << "C: " << std::is_nothrow_copy_assignable<C>::value << std::endl; return 0; }
Output:
=>using boolalpha
=>without using boolalpha
Comments