Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
parallel_markers.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <boost/range/combine.hpp>
4#include <boost/range/adaptor/filtered.hpp>
5#include <boost/range/adaptor/transformed.hpp>
6
7namespace sysio { namespace chain {
8
24template<typename DataRange, typename MarkerRange, typename Marker>
25DataRange filter_data_by_marker(DataRange data, MarkerRange markers, const Marker& markerValue) {
26 auto remove_mismatched_markers = boost::adaptors::filtered([&markerValue](const auto& tuple) {
27 return boost::get<0>(tuple) == markerValue;
28 });
29 auto ToData = boost::adaptors::transformed([](const auto& tuple) {
30 return boost::get<1>(tuple);
31 });
32
33 // Zip the ranges together, filter out data with markers that don't match, and return the data without the markers
34 auto range = boost::combine(markers, data) | remove_mismatched_markers | ToData;
35 return {range.begin(), range.end()};
36}
37
38}} // namespace sysio::chain
39
DataRange filter_data_by_marker(DataRange data, MarkerRange markers, const Marker &markerValue)
Return values in DataRange corresponding to matching Markers.