Ниже приведена упрощенная версия код, показывающий проблему.
https://godbolt.org/z/advGxdnPK
Код: Выделить всё
template
struct ValueT {};
struct Container1 {
using Value = ValueT;
};
struct Container2 {
using Value = ValueT;
};
template
struct Container3 {
using Base = T;
struct Value : ValueT {
typename Base::Value asBase() const { return {}; }
};
};
struct Container4 {
using Value = ValueT;
};
void handle(const Container1::Value &v) {}
void handle(const Container2::Value &v) {}
template
void handle(const typename Container3::Value &v) {
return handle(v.asBase());
}
// intentionally omitted
// void handle(const Container4::Value &v) {}
int main()
{
Container1::Value v1;
Container2::Value v2;
Container3::Value v31;
Container3::Value v32;
Container4::Value v4;
// These should compile.
handle(v1);
handle(v2);
handle(v31);
handle(v32);
// This one should fail to compile.
handle(v4);
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... f-a-templa