Boost logo

Boost Users :

Subject: Re: [Boost-users] [ptr_container] compiler error with BOOST_RESULT_OF_USE_DECLTYPE
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2011-03-01 15:30:11


A similar error happens even with tr1 result_of (i.e. without defining
BOOST_RESULT_OF_USE_DECLTYPE).
Minimal test case (fails to be compiled):

    #include <boost/ptr_container/indirect_fun.hpp>

    template <typename T>
    struct my_less
    {
       bool operator()(T const& t1, T const& t2) const { return t1 < t2; }

       template <typename Sig> struct result;
       template <typename This, typename Arg>
       struct result<This(Arg, Arg)>
       {
           typedef bool type;
       };
    };

    int main (int argc, char* argv[])
    {
        boost::void_ptr_indirect_fun<my_less<int>, int, int> f;

        return 0;
    }

The error occurred in the code (at line 105 of ptr_container/indirect_fun.hpp)
which determines the return type of unary function call operator of
class boost::void_ptr_indirect_fun<my_less<int>, int, int>:

    result_of<my_less<int>(int&)>::type operator()( const void* r ) const {...}

Since result_of<my_less<int>(...)> only works with two function parameters,
this code does not compile.

These issues, including OP's one, can be fixed by removing unary function call
operator of class boost::void_ptr_indirect_fun (i.e. making it BinaryFunction).

Hope this helps,
Michel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net