
Daniel Wallin wrote:
It's necessary to specialize the trait classes to handle fundamental types, for instance:
check_add<float, int*>
Would trigger a compilation error otherwise.
#include <boost/mpl/if.hpp> #include <boost/type_traits/is_fundamental.hpp> #include <boost/preprocessor/arithmetic/dec.hpp> // adding this in namespace boost::result_check_: template<class T> struct boxed_fundamental { operator T (); }; template <class T> struct make_arg { typedef typename add_reference< typename mpl::if_< is_fundamental<T> , boxed_fundamental<T> , T >::type >::type type; }; // changing the RESULT_CHECK_LOCAL_ARG macro to this: #define BOOST_RESULT_CHECK_LOCAL_ARG(z, n, text) \ static typename make_arg<T##n>::type \ BOOST_PP_CAT(_, BOOST_PP_INC(n)); // finally, weakening fallback overload within the // BOOST_RESULT_CHECK macro no_overload_tag function( \ BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(arity) \ , any BOOST_PP_INTERCEPT), ...); \ // ...should work