Skip to content

Strong semantics for Assignable.#150

Merged
ericniebler merged 1 commit into
ericniebler:masterfrom
CaseyCarter:semimovable
Nov 16, 2015
Merged

Strong semantics for Assignable.#150
ericniebler merged 1 commit into
ericniebler:masterfrom
CaseyCarter:semimovable

Conversation

@CaseyCarter

Copy link
Copy Markdown
Collaborator
  • Remove the default for Assignable's second parameter.
  • Remove prose requirements from Copyable and Movable, they are now provided by Assignable.
  • exchange and default-swap both now require MoveConstructible and Assignable instead of Movable.
  • Movable can now explicitly require Swappable, and all is right with the world.
  • Use Assignable instead of is_assignable in the specification of advance(I, S) to ensure the post-condition (i == s).

@CaseyCarter

Copy link
Copy Markdown
Collaborator Author

There's a second commit that simplifies the specification of advance(I, S) which became too complicated post-Kona. My Assignable changes make the requirements worse, or at least no better, this change is crystal clear.

@ericniebler

ericniebler commented Nov 14, 2015

Copy link
Copy Markdown
Owner

I'm not sure how I feel about this. Think of output iterators and proxy references. In what sense is some value assignable to *i when i is an ostream iterator? I feel like Assignable isn't the right place to put these semantics.

@CaseyCarter

Copy link
Copy Markdown
Collaborator Author

We don't use Assignable in Writable and MoveWritable for exactly that reason; the semantics are different.

EDIT: I've effectively co-opted Assignable from being only syntax to participating in the Object concept family.

EDIT 2: I've also used "equals" instead of == here as a quasi escape clause. A value is assignable to *i for an ostream iterator when the conceptual object it denotes in the output sequence is "equal" to the value assigned. E.g., *i = 42 should insert "42" into the output sequence, not "37". When T is StreamInsertable, which it must be for us to assign it through an ostream_iterator, we can construct a common type for T and string that validates that relationship.

@CaseyCarter

Copy link
Copy Markdown
Collaborator Author

Integrating these semantics for Assignable consistently with iterators would be in scope for https://github.com/CaseyCarter/stl2/issues/17, and definitely something I'll be thinking about at length.

@CaseyCarter

Copy link
Copy Markdown
Collaborator Author

There's a fresh pull with Assignable requiring Common. I've yanked the second commit with the advance changes from the branch since they are a separate issue, and I'm working on a more comprehensive cleanup of Sentinel / SizedIteratorRange / advance.

@ericniebler

Copy link
Copy Markdown
Owner

I'm not seeing the Common requirement of Assignable. Did you forget to add it?

@CaseyCarter

Copy link
Copy Markdown
Collaborator Author

I'm not seeing the Common requirement of Assignable. Did you forget to add it?

I reset the branch, and ran git commit --amend without adding the changes to the index. Yay me.

* Remove the default for Assignable's second parameter.
* Remove prose requirements from Copyable and Movable, they are now provided by Assignable.
* exchange and default-swap both now require MoveConstructible and Assignable instead of Movable.
* Movable can now explicitly require Swappable, and all is right with the world.
* Use Assignable instead of is_assignable in the specification of advance(I, S) to ensure the post-condition (i == s).
ericniebler added a commit that referenced this pull request Nov 16, 2015
Strong semantics for Assignable.
@ericniebler ericniebler merged commit 9d9adae into ericniebler:master Nov 16, 2015
@CaseyCarter CaseyCarter deleted the semimovable branch November 17, 2015 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants