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

Conform std::iterator_traits<fmt::appender> to [iterator.traits]/1 #4185

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

CaseyCarter
Copy link
Contributor

@CaseyCarter CaseyCarter commented Oct 2, 2024

In addition, the types

iterator_traits<I>::pointer
iterator_traits<I>::reference

shall be defined as the iterator’s pointer and reference types; that is, for an iterator object a of class type, the same type as decltype(a.operator->()) and decltype(*a), respectively. The type iterator_traits<I>::pointer shall be void for an iterator of class type I that does not support operator->. Additionally, in the case of an output iterator, the types

iterator_traits<I>::value_type
iterator_traits<I>::difference_type
iterator_traits<I>::reference

may be defined as void.

Also removes the unnecessary member types from basic_appender.

> In addition, the types
> ```c++
> iterator_traits<I>::pointer
> iterator_traits<I>::reference
> ```
> shall be defined as the iterator’s pointer and reference types; that is, for an iterator object `a` of class type, the same type as `decltype(a.operator->())` and `decltype(*a)`, respectively. The type `iterator_traits<I>::pointer` shall be void for an iterator of class type `I` that does not support `operator->`. Additionally, in the case of an output iterator, the types
> ```c++
> iterator_traits<I>::value_type
> iterator_traits<I>::difference_type
> iterator_traits<I>::reference
> ```
> may be defined as `void`.
@CaseyCarter
Copy link
Contributor Author

CaseyCarter commented Oct 2, 2024

Some C++20 tests that my naive local build didn't enable apparently want to use basic_appender without the iterator_traits specialization. I'll need to bring back at least the nested difference_type.

EDIT: Not exactly. The issue here was that I forgot the "void difference_type for output iterators" rule is only preserved for backwards compatibility with legacy iterators and all of the C++20 iterator concepts reject such an iterator.

The warning suppression just triggers another warning on a different compiler. Declare defeat.

This reverts commit 1accf6c.
@CaseyCarter
Copy link
Contributor Author

Ok, this now compiles FMT_PEDANTIC C++20 on at least MSVC and GCC. Sorry for the noisy PR =)

@vitaut vitaut merged commit e62c41f into fmtlib:master Oct 3, 2024
45 checks passed
@vitaut
Copy link
Contributor

vitaut commented Oct 3, 2024

Thank you!

@CaseyCarter CaseyCarter deleted the iterator_traits branch October 3, 2024 16:24
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