Problematic traits for ``streamer`` primary template
DNKpp opened this issue · 4 comments
Hello,
with the arise of c++20 and its ranges namespace, providing views as parameters become more and more common. Unfortunatly trompeloeil
doesn't fully support that, because the traits for the streamer
primary template aren't precise enough.
Currently we have
template <typename T,
bool = is_output_streamable<T>::value,
bool = is_collection<detail::remove_reference_t<T>>::value>
struct streamer
This is problematic in situations, where T
provides begin
and end
members, but only for non-const access. This may and will happen, when you use some advanced views. Unfortuantly this results in a huge compile error.
Have a look at std::views::owning, which always offers a begin
and end
implementation, but conditionally enables the const overloads.
I think, the constraint can simply be fixed by simply adding const (at least in my project that works like a charm), as the streamer also uses a const T&
.
template <typename T,
bool = is_output_streamable<const T>::value,
bool = is_collection<detail::remove_reference_t<const T>>::value>
struct streamer
EDIT: An alternative would be, to relax the streamer::print
param to non-const, but this is probably not desired, as a streamer
should not alter the streamed object in any way. So, I think it would be best, to stick with the const T&
and strengthening the traits.
So, any comments on this? Shall I compile a pull request or is there any information needed?
Sorry, I completely missed this. Thank you for pinging me. Please do make a PR, that would be very much appreciated.
Thank you so much for the fix. I'm leaving this open until a new release has been tagged.
Tagged v46 so closing now. Thanks again.