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

[allocator.requirements.general] The meaning of "parameterized in terms of allocators" seems unclear #5528

Open
frederick-vs-ja opened this issue Jun 15, 2022 · 6 comments

Comments

@frederick-vs-ja
Copy link
Contributor

[allocator.requirements.general]/1 says

All of the string types, containers (except array), string buffers and string streams ([input.output]), and match_results are parameterized in terms of allocators.

It's not very clear for me whether this sentence imposes some normative requirements, or if it does, what the requirements are, and [syncstream] is not yet covered.

Perhaps it means

If any template in [strings], [containers], [input.output], or [re] is instantiated and any template parameter named Allocator, Alloc, or SAlloc is substituted with a type that does not meet the Cpp17Allocator requirements, the behavior is undefined.

Not sure whether an LWG issue is needed.

@frederick-vs-ja frederick-vs-ja changed the title [allocator.requirements.general] The meaning "parameterized in terms of allocators" seems unclear [allocator.requirements.general] The meaning of "parameterized in terms of allocators" seems unclear Jun 15, 2022
@jwakely
Copy link
Member

jwakely commented Jun 15, 2022

No, there is requirement imposed by that wording. It's just telling you that you can use allocators with them.

@jwakely
Copy link
Member

jwakely commented Jun 15, 2022

i.e. they have a template parameter that gets substituted with an allocator type.

If those class templates have a precondition that their Allocator parameter meets the Allocator requirements, then those class templates should state that themselves. [allocator.requirements.general] is the wrong place to do that.

@frederick-vs-ja
Copy link
Contributor Author

So... is the current wording implying that basic_syncbuf<CharT, Traits, NonAllocator> may be well-defined, while basic_osyncstream<CharT, Traits, NonAllocator> results in UB?

@jwakely
Copy link
Member

jwakely commented Jun 15, 2022

No. Like I said, there is no normative requirement being imposed here.

It's just an informative remark saying "hey, there are types in the library that have a template parameter where you can put an allocator". It's not saying "and if you do it wrong you will die".

The list of types is incomplete, which should be fixed, but you should not be trying to infer some deep meaning from this sentence, or from the fact the list is incomplete.

@frederick-vs-ja
Copy link
Contributor Author

Oh I see. Thank you for interpretation!

The Cpp17Allocator requirement is seldom used in the library spec. Is it intended that most allocator-aware utilities (e.g. containers) don't actually require their allocator_type to be Cpp17Allocator?

@jensmaurer
Copy link
Member

Yes. Those places use the magic word "allocator", which is defined in [allocator.requirements.general]p1 (note italics). So, anywhere we say "allocator" we mean a class satisfying [allocator.requirements.general].

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

No branches or pull requests

3 participants