Auto variable to store function pointer to std::max

前端 未结 2 1422
南笙
南笙 2021-01-20 11:28

I\'m trying to pass function std::max as template parameter to a templated function, but for some reasons compiler prints error that function type cannot be ded

2条回答
  •  甜味超标
    2021-01-20 11:59

    std::max has more than one template overloads; you can use static_cast to specify which one should be used.

    static_cast may also be used to disambiguate function overloads by performing a function-to-pointer conversion to specific type

    e.g.

    auto f = static_cast(std::max);
    

提交回复
热议问题