How to pass const / non-const member function to BOOST_TYPEOF?

#include <boost/typeof/typeof.hpp>
struct Test
{
    const int& foo();
   // const int& foo() const;
};

int main()
{
    BOOST_TYPEOF(&Test::foo) ss;
}

This code compiles. After giving up the second function, I get an error because it does not know which function is foogiven. How can I pass a const or nonconst function here?

The problem is here:

template<typename Class, typename T>
struct MemberFuctionHasConstRefReturnType
{
    static const bool value = false;
};

template<typename Class, typename T>
struct MemberFuctionHasConstRefReturnType<Class, const T&(Class::*)()const>
{
    static const bool value = true;
};

This metafound checks if the return type of a member function is a const reference. I can not pass it const / non-const.

+4
source share

All Articles