Boost logo

Boost Users :

From: Agoston Bejo (gusz1_at_[hidden])
Date: 2004-12-17 14:03:15


[Platform: VC++7.1 (I always forget to mention this, only that's why I added
it now.)]

Actually what you have suggested is one of the two workarounds I came
accross when googling the net.
The other one was this (IMHO it would be slightly more elegant if it
worked):

cout << *find_if(ia, ia+5, boost::not1(
   make_adaptable<bool, int>(bind(equ, _1, 1)))) << endl;

But it generated an error. (I separated the first - and thus most relevant,
I suspect - part of the error message from the rest for better readibility.)
It is quite cryptic for me. It's strange that it does not refer to the above
line in the source, only to boost/functional.hpp. (Although it is obviously
that line that causes this mess, because commenting out makes the program
correctly compilable.) Can this be a sign of broken implementation?

The error message:

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\boost\functional.hpp(167) : error C3848: expression having
type 'const boost::unary_traits<Operation>::function_type' would lose some
const-volatile qualifiers in order to call
'boost::_bi::af1<R,A1,F>::result_type boost::_bi::af1<R,A1,F>::operator
()(A1)'
        with
        [
            Operation=boost::_bi::af1<bool,int,boost::_bi::bind_t<bool,bool
(__cdecl
*)(int,int),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,b
oost::_bi::list_av_2<boost::arg<1>,int>::B2>>>
        ]
        and
        [
            R=bool,
            A1=int,
            F=boost::_bi::bind_t<bool,bool (__cdecl
*)(int,int),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,b
oost::_bi::list_av_2<boost::arg<1>,int>::B2>>
        ]

--------------------------------------------

        c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\boost\functional.hpp(166) : while compiling class-template
member function 'bool boost::unary_negate<Predicate>::operator ()(const
boost::call_traits<T>::param_type) const'
        with
        [
            Predicate=boost::_bi::af1<bool,int,boost::_bi::bind_t<bool,bool
(__cdecl
*)(int,int),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,b
oost::_bi::list_av_2<boost::arg<1>,int>::B2>>>,

T=boost::unary_traits<boost::_bi::af1<bool,int,boost::_bi::bind_t<bool,bool
(__cdecl
*)(int,int),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,b
oost::_bi::list_av_2<boost::arg<1>,int>::B2>>>>::argument_type
        ]
        d:\prog\vcpp\Boost\xNot1Bind\xNot1Bind.cpp(24) : see reference to
class template instantiation 'boost::unary_negate<Predicate>' being compiled
        with
        [
            Predicate=boost::_bi::af1<bool,int,boost::_bi::bind_t<bool,bool
(__cdecl
*)(int,int),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,b
oost::_bi::list_av_2<boost::arg<1>,int>::B2>>>
        ]

"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:006501c4e430$541a0110$6401a8c0_at_pdimov2...
> Agoston Bejo wrote:
> > This does not seem to work, because the object bind returns does not
> > have an argument_type typedef.
> > Why is that so?
>
> Because the function objects created by bind do not have a fixed argument
> type.
>
> > Is there a workaround?
>
> For now, please use bind( logical_not<bool>(), bind( ... ) ).


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