I tried to use the wrapper boost::function<x>to store and convert my functional objects, and I want to know if there is a compilation check for "whether conversion from an arbitrary type Tto type is performedboost::function<x> .
Here is a sample code:
struct Functor {
int operator()(int) {
return 5;
}
};
STATIC_ASSERT( (IS_CONVERTIBLE<Functor,
boost::function<int (int)> >::value) );
STATIC_ASSERT( (IS_CONVERTIBLE<Functor,
boost::function<int (std::string)> >::value) );
Now - is there a way to implement validation IS_CONVERTIBLE?
I tried using type attribute checking boost::is_convertible, but it gives truefor any type Functor:
bool value1 = boost::is_convertible<Functor,
boost::function<int (int)> >::value;
bool value2 = boost::is_convertible<Functor,
boost::function<int (std::string)> >::value;
// At this point both 'value1' and 'value2' equal TRUE.
I also had the following attempts:
bool value = boost::is_convertible<Functor,
boost::function1<int, int> >::value;
bool value = boost::is_convertible<Functor,
std::unary_function<int, int>::value;
I really want to test the possibility of such a conversion at compile time, so if anyone knows how to implement this, I would appreciate it.
Thank.