Is there a identity_view?
denzor200 opened this issue · 8 comments
Hi. I need a simple wrapper that doesn't have any side effects on the wrapped sequence. Does this library support it? Or is there a shortest way to implement it? To implement >20 tag dispatched functions - is not a short way:(
What do i mean..
For example:
vector<int, std::string> v(12, "Hello world");
identity_view<vector<int, float>> view(v);
std::cout << at_c<0>(view) << std::endl; // Will print 12
std::cout << at_c<1>(view) << std::endl; // Will print Hello world
It's just example for a vector but i expect that identity_view will work with any valid fusion sequence.
No, there is no identity_view
. Would you like to contribute one?
The easiest way is to use transform_view
.
Yes, transform_view
is a good idea. But it's view has no at_key_impl
, key_of_impl
, and so others for associative sequence.
Respectively, if we get boost::fusion::map
and wrap it into transform_view
, then our map will lose its associative character.
Is that intended, or is this a flaw on the transform_view
side?
@djowel I implemented this in a rather cheeky way 😄
https://godbolt.org/z/3qn4x8ns5
Is that intended, or is this a flaw on the
transform_view
side?
It is not documented (*), but the ideal behavior would be that views should inherit the properties of its subjects. Again, PR would be great. It seems you have familiarity with fusion.
(* https://www.boost.org/doc/libs/1_65_1/libs/fusion/doc/html/fusion/view.html)
Again, PR would be great. It seems you have familiarity with fusion.
PR in process.. I started with the tests. The way I see it:
https://godbolt.org/z/3Y93n3dvd
I propose to make a set of generic tests that will be check any Sequence
for compliance with the Concept
.
Now in the fusion, view tests are absolutely not scalable:(
My example above show already implemented test for ForwardSequence
concept.
filter_view
passed this test good. But the current filter_view
will fail test for AssociativeSequence
concept, i suppose