Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should Writable require Semiregular, or "Move-Defaultable" #240

Closed
CaseyCarter opened this issue Oct 27, 2016 · 2 comments
Closed

Should Writable require Semiregular, or "Move-Defaultable" #240

CaseyCarter opened this issue Oct 27, 2016 · 2 comments

Comments

@CaseyCarter
Copy link
Collaborator

CaseyCarter commented Oct 27, 2016

P0022R2 changes the Readable concept by replacing the Semiregular requirement with Movable and DefaultConstructible; this allows move-only types like unique_ptr<int> and optional<thread> to model Readable.

P0022R2 notably does not make the symmetric change to the Writable concept. Why should I be forbidden to write to these move-only types from which I may read?

Note that this discrepancy is exacerbated by the fact that both implementations (cmcstl2, range-v3) of the TS have already implemented the same relaxation for Writable.

EDIT:

Proposed Resolution

[Editorial note: Change the definition of Writable ([iterators.writable]) as follows: --end note]

template <class Out, class T>
concept bool Writable() {
-  return Semiregular<Out>() &&
+  return Movable<Out>() && DefaultConstructible<Out>() &&
    requires(Out o, T&& t) {
      *o = std::forward<T>(t); // not required to be equality preserving
    };
}
@ericniebler
Copy link
Owner

I think it was just an oversight.

@ericniebler
Copy link
Owner

ericniebler commented Oct 31, 2016

Huh. Where do we currently require that iterators are copyable? Suggest: we add Semiregular to the Iterator concept. EDIT: We get that from WeaklyIncrementable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants