This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4059. Leaky abstraction in join_with_view's iterator

Section: 26.7.15.3 [range.join.with.iterator] Status: New Submitter: S. B. Tam Opened: 2024-03-23 Last modified: 2024-03-25

Priority: Not Prioritized

View other active issues in [range.join.with.iterator].

View all other issues in [range.join.with.iterator].

View all issues with New status.

Discussion:

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.)

Proposed resolution: