Re: copying elements from a <list> to <deque>
On Sep 25, 8:11 pm, arnuld <geek.arn...@gmail.com> wrote:
On Sep 25, 2:56 pm, James Kanze <james.ka...@gmail.com> wrote:
I'm not sure that I agree with either of these recommendations.
Both smack of obfuscation, and forcing things just to use a
standard (or non-standard, in the case of copy_if) algorithm.
For a more experienced programmer, I might consider a
std::deque< int > evens(
boost::make_filter_iterator< IsEven >( ilist.begin(),
boost::make_filter_iterator< IsEven >( ilist.end(),
ilist.end() ) ) ;
std::deque< int > odds(
boost::make_filter_iterator< IsOdd >( ilist.begin(),
boost::make_filter_iterator< IsOdd >( ilist.end(),
ilist.end() ) ) ;
This allows correct initialization; it would even allow making
evens and odds const. But it still requires moving the test out
of the loop, and even out of the function. And I'm pretty sure
that it's not the intent of the exercise.
I am trying this but can not copile my program with that without
errors. I am using remove_copy_if as suggested by Kai-Uwe Bux
(remember the _1 ;-)
Do you have Boost correctly installed? Are you including all of
the necessary Boost header files, and passing the necessary
options to the compiler so that it finds them (and the Boost
library, although I don't think either Kai-Uwe's suggestion or
mine actually require linking against the library).
but still I am interested in this use of boost library. I have
copied the code you wrote but then I am not able to get what
to do to make use of this make_filter_iterator.
any explanation ?
The real explanation is that you're jumping too far ahead of
where you are in the learning cycle. Learn the basics first;
there's time enough for Boost later.
Other than that, of course, you have to ensure that Boost is
correctly installed, that the compiler is passed all of the
necessary options, etc. (Under Unix, for example, you'll need
at least an additional -I option, and perhaps also an additional
-l. With VC++, that's a /I option and an additional library to
link against.) But seriously: I prefixed my suggestion with
"For a more experienced programmer". I did so for a reason.
Don't worry about it yet.
James Kanze (GABI Software) email:firstname.lastname@example.org
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34