std::vector<bool>
是否使用POPCNT
指令来计算std::count
算法的结果?
如果否,是否可以在不复制粘贴整个向量的情况下实现?为此,我需要访问实际上存储在该向量中的unsigned int
值,可以吗?
如果有关系,我只需要VC ++ 2017解决方案。
答案 0 :(得分:2)
per awaited item while the first one doesn't. Is this still going through the
不幸没有为std::count
使用popcnt
(至少在GNU C ++标准库中)。
std::vector<bool>
也不提供对其原始存储的访问,std::vector<bool>
返回std::vector<bool>::data
。
另一种解决方案是使用void
。 boost::dynamic_bitset<>
使用boost::dynamic_bitset<>::count
指令,请参见assembly output。
GNU C ++ popcnt
是次最佳实现的,其大小为40个字节。 std::vector<bool>
是32。