Skip to content

@rkennedy /boost-join-example.cpp
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Demonstration of Boost.Range to join multiple containers into a single sequence
#include <vector>
#include <deque>
#include <string>
#include <iostream>
#include <boost/range/join.hpp>
int main() {
// Iterated-over containers can be different types, as long as the
// value types are the same (string, in this case).
std::vector<std::string> vec1 = { "one", "two", "three" };
std::deque<std::string> deq2 = { "four", "five", "six" };
std::vector<std::string> vec3 = { "seven", "eight", "nine" };
auto range1_2 = boost::join(vec1, deq2);
auto range12_3 = boost::join(range1_2, vec3);
for (auto it = boost::begin(range12_3); it != boost::end(range12_3); ++it)
std::cout << *it << ' ';
// output: one two three four five six seven eight nine
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.