Reference:
Eric Niebler raised a question:
Answer is elaborated in book "C++ Templates The Complete Guide Second Edition"
13.2.1 Argument-Dependent Lookup
14.3.1 Two-Phase Lookup
i.e.
for first fn call is an ADL call, thus (quoted from @Lewis Baker)
"When passing an argument to an ADL call the compiler needs to build a list of associated entities. This includes looking at associated entities of all template args, which includes inspecting the base classes of those template args, which requires instantiating those types."
template <bool B>
struct S {
static_assert(B);
};
template <class>
struct T {};
template <class U>
void fn(T<U>&&) {}
int main() {
fn(T<S<false>>{}); // static assert ERROR, why?
::fn(T<S<false>>{}); // OK
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.