Boost logo

Boost :

Subject: Re: [boost] review request: addition to type_traits library of is_less_comparable<T, U> and others
From: Frédéric Bron (frederic.bron_at_[hidden])
Date: 2009-12-08 17:27:59


> 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;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk