I know set() function for a already constructed bitset object, but I need a constructed bitset which all bits are 1. The situation is a default function parameter. for example:
void bar(std::bitset<100> flags = X) {
}
what X should be, -1 may works for first 64 bits, but not all.
Or combine into 1 statement:
In C++11:
Edit: or better use
std::move
to avoid copy becauseset
return lvalue referencebitset&
:Performance of
operator ~
,flip()
andset()
:Output:
Surprisingly
set()
is much faster thanoperator ~
andflip