libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc
raw| 1 | // { dg-do compile { target c++11 } } |
| 2 | |
| 3 | #include <type_traits> |
| 4 | |
| 5 | class S { |
| 6 | operator int(); |
| 7 | friend void g(); // #1 |
| 8 | }; |
| 9 | |
| 10 | void |
| 11 | g() |
| 12 | { |
| 13 | int i = 0; |
| 14 | S s; |
| 15 | i = s; // this works, because we're inside a friend. |
| 16 | |
| 17 | // But the traits are evaluated in "a context unrelated to either type". |
| 18 | static_assert( ! std::is_assignable<int&, S>::value, "unfriendly"); |
| 19 | #if __cplusplus >= 201703L |
| 20 | static_assert( ! std::is_assignable_v<int&, S>, "unfriendly"); |
| 21 | #endif |
| 22 | } |