
8 Dec
2009
8 Dec
'09
10:27 p.m.
It is (almost) possible to check the exact return type.
template<class Expected, class Actual> boost::is_same<Expected, Actual> test(const Actual&);
Does not work with void return operator: #include <iostream> #include <boost/typeof/typeof.hpp> #include <boost/type_traits/is_same.hpp> template<class Expected, class Actual> boost::is_same<Expected, Actual> test(const Actual&){}; bool f(){} void g(){} int main() { typedef BOOST_TYPEOF(test<bool>(f())) type_f; std::cout << "f:" << type_f::value << std::endl; typedef BOOST_TYPEOF(test<bool>(g())) type_g; std::cout << "g:" << type_g::value << std::endl; return 0; }