I am trying to copy data from one container type to another container type, the containers are both double dimensional vectors, i am using boost::combine and boost::tie to iterate over the containers, the code builds fine but throws a bad_alloc when run. i am not able to understand why a simple code like below throw bad_alloc, what am i doing wrong ?? also what are the other strategies to copy data between containers when they are multi-dimensional.
#include <vector>
#include <iostream>
#include <boost/foreach.hpp>
#include <boost/container/small_vector.hpp>
#include <boost/range/combine.hpp>
#include <algorithm>
#include <tuple>
int
main(int ac, char **av)
{
std::vector<std::vector<int>> bv(1, std::vector<int>(4, 99));
boost::container::small_vector<boost::container::small_vector<int, 4>, 1> bvv;
decltype(bv)::value_type v1;
decltype(bvv)::value_type v2;
BOOST_FOREACH(boost::tie(v1, v2), boost::combine(bv, bvv)){
for ( auto &e : v1 )
v2.push_back( e );
}
return 0;
}