boost::not1(boost::bind(...))

This does not seem to work, because the object bind returns does not have an argument_type typedef. Why is that so? Is there a workaround? Thx, Agoston

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( ... ) ).

[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
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( ... ) ).

Agoston Bejo wrote:
[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
(bind(equ, _1, 1)))) << endl; But it generated an error.
Compiles here (but the linker dies with an internal error ;-) ). Which version of Boost are you using? (Please post complete programs in the future. Thanks in advance.)

Boost 1.32 (I've downloaded it last week or so).
On the bottom you can find the complete program. (In other newsgroups I
often saw people complaining about having to read the whole source code - I
suppose they didn't mean minimal examples, am I right?)
"Peter Dimov"
Agoston Bejo wrote:
[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
(bind(equ, _1, 1)))) << endl; But it generated an error.
Compiles here (but the linker dies with an internal error ;-) ). Which version of Boost are you using?
(Please post complete programs in the future. Thanks in advance.)
There it goes:
--------------------------------------------------
// xNot1Bind.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include

Agoston Bejo wrote:
Boost 1.32 (I've downloaded it last week or so).
On the bottom you can find the complete program. (In other newsgroups I often saw people complaining about having to read the whole source code - I suppose they didn't mean minimal examples, am I right?)
Probably. :-) I had to remove the include of "stdafx.h", add one for <algorithm>, and change to int main() With these changes, it gives me an output of '2'. I'm always using the CVS version of Boost, but there've been no changes post-1.32 to Bind or functional.hpp. make_adaptable was indeed missing const operator() overloads in Boost 1.31, though.
participants (2)
-
Agoston Bejo
-
Peter Dimov