$ g++ c.cpp
c.cpp: In function ‘int main()’:
c.cpp:22:18: error: address of overloaded function with no contextual type information
22 | FP f= true ? &std::string::find_last_not_of : &std::string::find_first_not_of;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c.cpp:22:51: error: address of overloaded function with no contextual type information
22 | FP f= true ? &std::string::find_last_not_of : &std::string::find_first_not_of;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main() { using FP = size_t (std::string::*) (const std::string &str, size_t pos) const;
FP func;
if (true) { func = &std::string::find_last_not_of;
} else { func = &std::string::find_first_not_of; } } [/code] Если я попытаюсь упростить оператор if до одного выражения, например: [code]FP func = true ? &std::string::find_last_not_of : &std::string::find_first_not_of; [/code] g++ 14.2.1 отклоняет его с помощью: [code]$ g++ c.cpp c.cpp: In function ‘int main()’: c.cpp:22:18: error: address of overloaded function with no contextual type information 22 | FP f= true ? &std::string::find_last_not_of : &std::string::find_first_not_of; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ c.cpp:22:51: error: address of overloaded function with no contextual type information 22 | FP f= true ? &std::string::find_last_not_of : &std::string::find_first_not_of; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [/code] В чем здесь проблема?