What are my options for using std::get<>() and std::tie<>() along with boost constructs?
Example: I want to use a range-based for-loop to iterate over multiple containers. I can implement a zip function that uses boost::zip_iterator .
#include <boost/iterator/zip_iterator.hpp> #include <boost/range.hpp> template <typename... TContainer> auto zip(TContainer&... containers) -> boost::iterator_range<boost::zip_iterator<decltype(boost::make_tuple(std::begin(containers)...))>> { auto zip_begin = boost::make_zip_iterator(boost::make_tuple(std::begin(containers)...)); auto zip_end = boost::make_zip_iterator(boost::make_tuple(std::end(containers)...)); return boost::make_iterator_range(zip_begin, zip_end); }
Now I can use it as follows:
std:list<int> a; std::vector<double> b; ... for (auto t : zip(a, b)) {
Problems arise when I call some other method that expects std::tuple or std::pair - I need to convert), because the rest of the code uses std::tuples , or when std::get<>() used in the template std::get<>() and / or std::tie() .
I found some fixes that add std::tuple support for zip_iterator , but they do not apply in my version (I use Boost 1.54).
Am I missing something? What are my options to force zip_iterator to return std::tuple or to do std::get , std::tie , etc. Available for boost types?
c ++ boost c ++ 11 stl tuples
Johnny
source share