Skip to content

Give collection_size_type explicit increment, decrement, and stream extractor - #358

Open
gennaroprota wants to merge 1 commit into
developfrom
fix/drop-mutable-reference-conversion-from-collection-size-type
Open

Give collection_size_type explicit increment, decrement, and stream extractor#358
gennaroprota wants to merge 1 commit into
developfrom
fix/drop-mutable-reference-conversion-from-collection-size-type

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

collection_size_type had no increment, decrement, or stream extractor but had an implicit conversion to a modifiable reference to its stored size (operator base_type &) which allowed the built-in operators to apply.

Remove that mutable-reference conversion and provide the operations the library actually needs explicitly: pre/post ++ and --, and an operator>> for input (templated on the character type, so it serves narrow and wide text and XML archives). The read-only operator base_type() const is kept: output, container sizing, and comparisons go through it, so no call sites change.

The on-disk format is unchanged. Binary archives already serialize the type bitwise; text and XML still read and write the same size through is >> x / os << x.

Adds test_collection_size_type, which checks the operators directly and round-trips a value through every archive type.

Closes #192.

…xtractor

`collection_size_type` had no increment, decrement, or stream extractor
but had an implicit conversion to a modifiable reference to its stored
size (`operator base_type &`) which allowed the built-in operators to
apply.

Remove that mutable-reference conversion and provide the operations the
library actually needs explicitly: pre/post `++` and `--`, and an
`operator>>` for input (templated on the character type, so it serves
narrow and wide text and XML archives). The read-only `operator
base_type() const` is kept: output, container sizing, and comparisons go
through it, so no call sites change.

The on-disk format is unchanged. Binary archives already serialize the
type bitwise; text and XML still read and write the same size through
`is >> x` / `os << x`.

Adds test_collection_size_type, which checks the operators directly and
round-trips a value through every archive type.

Closes #192.
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.

collection_size_type missing increment/decrement operators

1 participant