libstdc++: Add test for type traits not having friend access
This ensures that the std::is_assignable and std::is_assignable_v traits are evaluated "in a context unrelated" to the argument types. libstdc++-v3/ChangeLog: * testsuite/20_util/is_assignable/requirements/access.cc: New test.
This commit is contained in:
parent
71c828f845
commit
5924c7d584
1 changed files with 22 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
// { dg-do compile { target c++11 } }
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
class S {
|
||||
operator int();
|
||||
friend void g(); // #1
|
||||
};
|
||||
|
||||
void
|
||||
g()
|
||||
{
|
||||
int i = 0;
|
||||
S s;
|
||||
i = s; // this works, because we're inside a friend.
|
||||
|
||||
// But the traits are evaluated in "a context unrelated to either type".
|
||||
static_assert( ! std::is_assignable<int&, S>::value, "unfriendly");
|
||||
#if __cplusplus >= 201703L
|
||||
static_assert( ! std::is_assignable_v<int&, S>, "unfriendly");
|
||||
#endif
|
||||
}
|
Loading…
Add table
Reference in a new issue