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

fix: un-qualify Range::value_type for compatibility with fmt v11 #2265

Closed
wants to merge 1 commit into from

Conversation

mhx
Copy link
Contributor

@mhx mhx commented Jul 24, 2024

folly::StringPiece no longer works with fmt v11 due to value_type being const char instead of the char expected by fmt.

Looking at std::span, which is probably the closest equivalent to folly::Range, value_type is defined as std::remove_cv_t<T>, so I think it would make sense for folly::Range to define value_type similarly, i.e. without cv-qualification.

This change removes cv-qualifiers from value_type and replaces the the use of value_type& by reference and const value_type& by the newly introduced const_reference.

See fmtlib/fmt#4086 for additional context.

folly/Range.h Outdated Show resolved Hide resolved
`folly::StringPiece` no longer works with fmt v11 due to `value_type`
being `const char` instead of the `char` expected by fmt.

Looking at `std::span`, which is probably the closest equivalent to
`folly::Range`, `value_type` is defined as `std::remove_cv_t<T>`, so
I think it would make sense for `folly::Range` to define `value_type`
similarly, i.e. without cv-qualification.

This change removes cv-qualifiers from `value_type` and replaces the
the use of `value_type&` by `reference` and `const value_type&` by
the newly introduced `const_reference`.
@mhx mhx force-pushed the mhx/range-unqualify-value-type branch from b2b311d to d00d4a6 Compare July 24, 2024 16:42
@facebook-github-bot
Copy link
Contributor

@vitaut has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@michel-slm
Copy link
Contributor

Thanks! I'll add this to the Fedora build while you work with @yfeldblum to get this merged upstream

facebook-github-bot pushed a commit that referenced this pull request Jul 26, 2024
Summary:
Currently, `UTF8StringPiece` is defined in terms of `Range<boost::u8_to_u32_iterator<...>>`. But this makes certain necessary changes in `Range` fail to compile. Change `UTF8StringPiece` to be a standalone range type.

Unblocks {D60181556} (aka #2265), which intends to resolve a problem blocking `folly::StringPiece` from being formattable with `fmt::format` since `fmt-11`.

Reviewed By: vitaut

Differential Revision: D60252703

fbshipit-source-id: 282d166c1456bdc5e311f4ed7c3ce8eae91422b0
@vitaut
Copy link
Contributor

vitaut commented Jul 30, 2024

Superseded by 21e8dcd but thanks for working on this!

@vitaut vitaut closed this Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants