MS's STL already uses metaprogramming to help the optimizer produce
optimized code. As an example, std::fill delegates to std::memset
if safe, which has the advantage of guaranteed good performance in
Debug mode, as well as not having to rely on the optimizer to salvage
reasonable ASM out of the actual code.
I would like optimizations like this to also happen when calling various
algorithms on std::vector<bool>, which currently does not happen.
As an example, this code
void clean_out(std::vector<bool>& vec) {
std::fill(vec.begin(), vec.end(), false);
}
should end up calling memset, rather than doing whatever this is.
Other algorithms that could be optimized:
std::copy
std::count
std::find
std::equal
- possibly others?
This would also improve the performance of std::vector<bool>'s member functions, as it internally uses std algorithms.