Re: any_of, all_of, none_of
Am 28.08.2011 20:20, schrieb gast128@hotmail.com:
[..]
Actually I have 2 requests:
- all / all_if: value and predicate variants. This one I was posting
about.
If you want to realize I suggest that you make a official proposal and
send it for consideration to the committee.
- all / all_if working on ranges instead of [begin, end>. This will
probably offered by Boost.Range in time
This won't work without a complete proposal for ranges in the library.
It wouldn't make sense to provide such a support for a single function
template.
If the STL doesn't offer a value based one, we can still define one in
our code, preferably in the implementation using the all_of varaint.
Since this is a template (look at the function prototype in previous
post) we cannot use the lambda expressions.
You claimed this several times and I asked for some evidence. Why
shouldn't this work:
#include <algorithm>
#include <iterator>
template <typename For, typename ValueType>
bool all(For first, For last, const ValueType& rValue)
{
return std::all_of(first, last,
[&](const typename std::iterator_traits<For>::value_type& value)
{ return rValue == value; }
);
}
?
We can use the bind
version but we might have here a small performance or build time
drawback. it would be better if the STL just had defined this in the
beginning (and afaiac with a consistent naming convention).
There is no reason for binding it, as shown above. If you are not
satisfied with the current state, you should make a proposal, but be
aware that this will need some time for coming part of the next
standard. You should try to find some more reasons except for "just for
completeness", because a standard with millions of variants of an
algorithm does not necessarily improve the state.
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]