
On 08/02/13 11:12, oswin krause wrote:
Hi,
Is it possible to evaluate, whether a certain argument type given to a functor will lead to a valid expression with the result_of template?
i am trying to achieve the following, maybe there is a better way to do it:
template<class T, class F> Container< typename boost::result_of<F(T)>::type > transform( Container<T> c, F f, std::disable_if<valid_expression<F(Block<T>) > >::type* dummy = 0
What do you call a valid expression? F(Block<T>) is certainly not an expression. You could test if F::result< F(Block<T>) >::type exists, or whether declval<F>()(declval< Block<T> >()) is a valid expression. Both can be done using SFINAE, the latter will require a recent enough compiler that supports generalized SFINAE (GCC does it since 4.6 I believe).