In the MCVE below, C++ has no trouble identifying that ints may be read or printed with stream I/O. But it thinks As can't be, despite the prototypes for << and >>.
#include <iostream>
using namespace std;
template<typename T>
concept Readable = requires(std::istream& in, T& t)
{
in >> t;
};
template<typename T>
concept Printable = requires(std::ostream& out, T t)
{
out << t;
};
int main()
{
class A {};
ostream& operator<< (ostream&, const A&);
istream& operator>> (istream&, A&);
std::cout << Readable<int> << Printable<int> << '\n';
std::cout << Readable<A> << Printable<A> << '\n';
return 0;
}
The output is
11
00
If I make the prototypes and the class global, the problem is fixed (it prints 11, not 00, for the 2nd line of output).
Obviously I'd make prototypes global normally. But I don't see how scoping rules let the constraint know where it was defined, as long as it is defined. Why doesn't it work when the prototypes are local?