Subject: [std-proposals] Missing logical identity in <functional>
From: Alexander Klein (xelalex_maker_at_[hidden])
Date: 2019-08-25 07:16:53
the other day I was trying to test whether all of the bits in a
std::vector< bool > were set or unset, but I couldn't come up with a
really elegant solution using the logical operations in <functional>,
because there seems to be no logical identity.
In short, given
std::vector< bool > v;
I think it should be possible to write:
const bool all_set = all_of ( v.cbegin(), v.cend(),
std::logical_identity< bool >() );
The current state of things in <functional> complicates this needlessly
by necessitating workarounds, some of which are obviously error-prone.
See the attachment for an example that will compile with g++ 4.8.4:
g++ -std=c++11 -pedantic all_bits.cpp
Would it be useful to write up a respective proposal?
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups