Can I initialize a vector<bool> to start with a sequence of 010101…etc? Or do I have to just initialize it with 0’s and loop thru and change every other value to 1?
Can I initialize a vector<bool> to start with a sequence of 010101…etc? Or do
Share
To expand on @zmbq’s answer, use
std::generate_nlike this:You would use
std::generateif thevectoralready had a size.If you don’t have a C++11 compiler…