Reputation: 321
I want to get pointer to boost::any::operator=, so i did this:
bool(__thiscall boost::any::*func)(const bool&) = &(boost::any::operator=<bool>);
but now, compiler says
initializing' : cannot convert from 'overloaded-function' to 'bool (__thiscall boost::any::* )(const bool &)' None of the functions with this name in scope match the target type
i also tried to make it this way:
bool(__thiscall boost::any::*func)(const bool&) = static_cast<(boost::any::*)(const bool&)>(&(boost::any::operator=<bool>));
but there is compiler says: "syntax error : '('" in this line
can anybody helps me, please?
P.S. I make instaces of boost::any in the code above
Upvotes: 0
Views: 146
Reputation:
You can not specify the arguments in the assignment of the member function pointer. This will do it:
#include <iostream>
#include <boost/any.hpp>
int main() {
boost::any any = false;
std::cout << boost::any_cast<bool>(any) << std::endl;
typedef boost::any& (boost::any::*assign_operator)(const bool&);
assign_operator assign = &boost::any::operator =;
(any.*assign)(true);
std::cout << boost::any_cast<bool>(any) << std::endl;
return 0;
}
Upvotes: 1