Title
Leaky abstraction in join_with_view's iterator
Status
new
Section
[range.join.with.iterator]
Submitter
S. B. Tam

Created on 2024-03-23.00:00:00 last changed 1 month ago

Messages

Date: 2024-03-23.00:00:00

join_with_view's iterator is defined in terms of variant, visit and get, which implies that the iterator operations throw bad_variant_access if the underlying variant is valueless-by-exception (which can happen if an underlying iterator has a throwing copy constructor).

IMO, the variant is an implementation detail and shouldn't be exposed. It's confusing for users to get bad_variant_access when user code does not deal with variant.

The spec of join_with_view is also inconsistent with concat_view as recently added to the working draft by P2542R8. The latter has "it_.valueless_by_exception() is false" as a precondition.

I believe that join_with_view should similarly require that inner_it_.valueless_by_exception() is false for each iterator operation.

(FWIW, MSVC STL implements join_with_view with a trimmed-down version of variant, and having to throw bad_variant_access causes a small maintenance burden.)

History
Date User Action Args
2024-03-23 00:00:00admincreate