Попытка спроектировать ответ, который я наткнулся на это странное поведение: < /p>
Код: Выделить всё
#include // for std::same_as
#include
#include
// dummy default declaration
template
void foo(T) = delete;
template
constexpr bool b_req = requires(T obj) {
{ foo(obj) } -> std::same_as;
};
// client types
struct S1 {};
struct S2 {};
// non-template candidate for S1
void foo(S1) { std::puts("foo(S1)"); }
int main() {
foo(S1{}); // calls the expected version
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79608912/requires-expression-looking-for-wrong-candidate-function-when-using-namespaces[/url]