This is an example of how to use a multi-level STL container, a vector of vectors, with Metall.
#include <iostream>
#include <boost/container/scoped_allocator.hpp>
#include <boost/container/vector.hpp>
namespace bc = boost::container;
using inner_vector_type = bc::vector<int, inner_vector_allocator_type>;
using outer_vector_type =
bc::vector<inner_vector_type, outer_vector_allocator_type>;
{
auto pvec =
manager.construct<outer_vector_type>(
"vec-of-vecs")(
pvec->resize(1);
(*pvec)[0].push_back(1);
pvec->emplace_back(1);
(*pvec)[1][0] = 2;
std::vector<int> local_row = {3, 4};
pvec->emplace_back(local_row.begin(), local_row.end());
}
{
auto pvec =
manager.find<outer_vector_type>(
"vec-of-vecs").first;
std::cout << (*pvec)[0][0] << std::endl;
std::cout << (*pvec)[1][0] << std::endl;
std::cout << (*pvec)[2][0] << std::endl;
std::cout << (*pvec)[2][1] << std::endl;
}
return 0;
}
int main()
Definition: jgraph.cpp:24