Open trueqbit opened 4 years ago
In order to make code even more easily readable, I started encapsulating the creation of a "transform" range adaptor that accesses a member variable:
inline constexpr auto fetch = [](auto memberPtr) { return boost::adaptors::transformed(std::bind(memberPtr, std::placeholders::_1)); }; // example sort(c | fetch(&Object::name));
This solves the boiler-plate code required otherwise:
sort(c | transformed(std::bind(&Object::name, std::placeholders::_1)));
Do you think this is a generic enough pattern worthwhile to be added to "boost range"?
In order to make code even more easily readable, I started encapsulating the creation of a "transform" range adaptor that accesses a member variable:
This solves the boiler-plate code required otherwise:
Do you think this is a generic enough pattern worthwhile to be added to "boost range"?