I’m pretty sure I’ve stumled across a bug in the concepts implementation of nvcc:
template <typename T>
struct S
{
T t;
template <typename U>
requires (false)
S& operator=(U&& t){
t.a();
return *this;
}
};
template <typename T>
struct S2 : S<T>
{
using S<T>::operator=;
};
int main()
{
int a;
S2<int&> s{a};
}
This results in the following error (Godbolt link):
<source>(15): error: template constraint not satisfied
<source>(7): note #3135-D: substitution of arguments "<S<int &>>" for requires-clause failed
<source>(7): note #3043-D: atomic constraint evaluates to false
detected during instantiation of class "S2<T> [with T=int &]"
(23): here
1 error detected in the compilation of "<source>".
Compiler returned: 2
The same does not happen in clang or gcc, and also only happens when using reference types & the using ...::operator=;
declaration - I assume this is a bug in nvcc? Any easy workarounds apart from falling back to SFINAE with std::enable_if_t
?