How to create custom view that is transformable? #1789
Unanswered
maichmueller
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
thanks for the excellent library! It has made my code much more expressive and elegant. I have a little issue with getting transform to work on my own views though.
TLDR: I want to create my own view which can be piped into
ranges::views::transform(...)
without problem. My current approach to derive fromview_base
does not seem to allow this.I have made a function that does nothing more than dereference the input perfect-forwards it, like so:
Here my custom view which captures this function:
Now I am using it on a simple vector of shared pointers to int and it works fine
prints
But piping it into a transform fails:
As can be seen on godbolt here:
https://godbolt.org/z/1KWMb34e4
Any advice on what I am missing would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions