View Library

Started by
3 comments, last by Eelco 15 years, 3 months ago
I was writing some code that involves a lot of lazy filtering of data. As i was writing this, i started to feel like i was reinventing the wheel, and indeed i was. The concept of a 'view' container adaptor as a predicate being applied to a range isnt a new one. So, i want to be able to write stuff like:

View lazy_set_intersection = filter_view(left, predicate_contains(right));
Where view is a container adaptor which iterates over the entries in left, skipping all entries for which the predicate doesnt evaluate to true. So i decided to quit my reinvention of the wheel. I figured that surely, boost must have a solid implementation of something like this included? I find it hard to believe, but it seems the answer is 'no'. All this stuff is included in boost/fusion for friggin metadata containers, but for plain old data containers, it isnt? wtf? STL? No luck either it seems. The best ive found so far is VTL, the View Template Library. It hasnt been updated since 2000, and generally, im not too convinced its all that optimal in terms of boost/stl compliance. Surely i must be missing something here?
Advertisement
As always, I'm probably missing something obvious, but what about remove_copy_if?
Quote:Original post by Gage64
As always, I'm probably missing something obvious, but what about remove_copy_if?


Its not a lazy implementation, it requires memory allocation.
On second thought, it seems quite decently designed. Still, it hasnt been updated since 2000, and it has only been downloaded a couple of hundered times since.

That doesnt seem right for something so usefull. Am i really not missing something?
Hmm, VTL isnt flexible enough to do what i want to do (which is, operations on unordered maps).

Guess i will have to write it myself then... should be quite easy using boost::filter_iterator

This topic is closed to new replies.

Advertisement