Boost type erasure error with free function const and non-const overloads

Viewed 141

This is the code.

BOOST_TYPE_ERASURE_FREE((has_arg1), arg1, 1)

namespace te = ::boost::type_erasure;

typedef te::any<
            ::boost::mpl::vector<
                te::copy_constructible<>,
                te::typeid_<>,
                te::destructible<>,
                te::assignable<>,
                has_arg1<Vector<Val>&( te::_self& )>,
                has_arg1<const Vector<Val>&( const te::_self& )>>> Bar;

struct Foo {
    Vector<Val> mVals;
};

const Vector<Val>& arg1(const Foo& f) {
    return f.mVals;
}

Vector<Val>& arg1(Foo& f) {
    return f.mVals;
}

BOOST_AUTO_TEST_CASE(Foo1) {
    Foo f;
    Bar i = f;
}

It fails with the following error. Any ideas why? Is this not possible using boost type erasure. I am using Clang++ 3.5 compiler.

      functions that differ only in their return type cannot be overloaded
BOOST_TYPE_ERASURE_FREE((has_arg1), arg1, 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
1 Answers
Related