| 1 |
#include <iostream> |
| 2 |
#include <type_traits> |
| 3 |
#include <string> |
| 4 |
|
| 5 |
using namespace std; |
| 6 |
|
| 7 |
class Foreign |
| 8 |
{ |
| 9 |
public: |
| 10 |
Foreign() = default; |
| 11 |
Foreign(string const &) noexcept |
| 12 |
{} |
| 13 |
|
| 14 |
Foreign(Foreign const &other) noexcept |
| 15 |
{ |
| 16 |
throw 1; |
| 17 |
} |
| 18 |
}; |
| 19 |
|
| 20 |
class String |
| 21 |
{ |
| 22 |
public: |
| 23 |
String() = default; |
| 24 |
String(String &&tmp) |
| 25 |
{} |
| 26 |
}; |
| 27 |
|
| 28 |
template <typename Type> |
| 29 |
class MyClass |
| 30 |
{ |
| 31 |
Type d_f; |
| 32 |
public: |
| 33 |
MyClass() = default; |
| 34 |
MyClass(MyClass &&tmp) |
| 35 |
: |
| 36 |
d_f(move(tmp.d_f)) |
| 37 |
{} |
| 38 |
}; |
| 39 |
|
| 40 |
int main() |
| 41 |
try |
| 42 |
{ |
| 43 |
cout << "TRAIT: " << is_nothrow_copy_constructible<Foreign>::value << '\n'; |
| 44 |
MyClass<String> s1{ move(MyClass<String>{} ) }; |
| 45 |
MyClass<Foreign> s2{ move(MyClass<Foreign>{} ) }; |
| 46 |
} |
| 47 |
catch (...) |
| 48 |
{ |
| 49 |
cout << "Exception\n"; |
| 50 |
} |