Range-v3 用法积累,及资料
1. view – 返回子集 sub_range
1
2
3
4
#include <ranges>
using dataset_slice_t = std::ranges::subrange<std::vector<rias::data_type::sample_data_t>::iterator>;
dataset_slice_t sub_range(it_min, it_max);
2. filter – 根据条件过滤出子集
1
2
3
Block blk;
auto ss = sample_dataset_->ds_ | std::views::filter([&](const sample_data_t& ds) { return ds.dbg_blk_id_ == blkId; });
std::ranges::for_each(ss, [&](const sample_data_t& ds) { blk.signals_.push_back(ds); });
本文由作者按照 CC BY 4.0 进行授权