Can the type of bookmarks in a template parameter of a non-type type include permission to overload the function passed as an argument to the template?

Further consideration of this issue . Assuming that placeholder can be used to output the result type of the function pointer that makes up the non-piggy template parameter. Does C ++ 17 allow overload resolution when passing the name of a template function - without knowing the type of result that is needed to perform implicit casting?

template <auto(*)(int)>
struct Foo { };

int bar(int);
float bar(float);

int main() {
    static_cast<void>(Foo<bar>{});
}

[gcc] as well as [clang] seem to be accepting the code.

+4
source share
1 answer

, Rakete1111. , , [dcl.type.auto.deduct]/4, :

, T ' . P T, auto U, , - , :: initializer_list. U, , P , - e. , . T ' U P.

[temp.deduct.call]/6 , :

P - , :

  • , , .

  • ( ), . , . overload set .

, .

+7

Source: https://habr.com/ru/post/1692831/


All Articles