Skip to content

DE282 24.04.4 Make enable_view less greedy LWG 3326 #278

@wg21bot

Description

@wg21bot

Since the difference between range and view is largely semantic, the
two are differentiated with the help of enable_view." (§3)

enable_view is designed as on opt-in trait to specify that a type is a
view. It defaults to true for types derived from view_base (§4.2) which
is clearly a form of opt-in. But it also employs a heuristic assuming
that anything with iterator == const_iterator is also view (§4.3).

This
is a very poor heuristic, the same paragraph already needs to define six
exceptions from this rule for standard library types (§4.2).

Experience in working with range-v3 has revealed multiple of our own
library types as being affected from needing to opt-out from the
"auto-opt-in", as well. This is counter-intuitive: something that was
never designed to be a view shouldn't go through hoops so that it isn't
treated as a view.

Proposed change:
Make enable_view truly be opt-in by relying only on explicit
specialisation or inheritance from view_base. This means removing 24.4.4
§4.2 - §4.4 and introducing new §4.2 "Otherwise, false".

Double-check if existing standard library types like basic_string_view
and span need to opt-in to being a view now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions