August 2017
Intermediate to advanced
438 pages
14h 19m
English
The flat containers are part of the Boost.Container library. We already saw how to use some of its containers in the previous recipes. In this recipe, we'll be using a flat_set associative container:
#include <boost/container/flat_set.hpp>
#include <algorithm>#include <cassert>int main() { boost::container::flat_set<int> set;
set.reserve(4096);
for (int i = 0; i < 4000; ++i) { set.insert(i); }
// 5.1 assert(set.lower_bound(500) - set.lower_bound(100) == 400); // 5.2 set.erase(0); // ...
Read now
Unlock full access