ericniebler / stl2

LaTeX and Markdown source for the Ranges TS/STL2 and associated proposals
88 stars 8 forks source link

transform_view should constrain the invocable's return type #581

Open ericniebler opened 5 years ago

CaseyCarter commented 5 years ago

I think the proper requirement is that it return a referenceable type. We can reuse the exposition-only can-reference concept, and/or admit that this constraint is useful enough to deserve a name. (And a better name, at that.)

timsong-cpp commented 5 years ago

What nonreferenceable type other than void is returnable?

CaseyCarter commented 5 years ago

What nonreferenceable type other than void is returnable?

None - the point is to constrain the return type to what's necessary for the view's uses, rather than forbidding things that we don't want. The latter supposes that we haven't missed a case we need to forbid, and requires maintenance if the core language changes in the future.

Yes, this argues that "referenceable type" is not the proper requirement, for example, functions are referenceable types (albeit not types that can be the return type of function). I think "object type or reference to such" is more precise.

JohelEGP commented 5 years ago

So is_object_v<remove_reference_t<invoke_result_t<F&, iter_reference_t<iterator_t<V>>>>>?