-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
remove_const from value_type of Range::value_type #2255
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in general, value_type in a range-alike type should not be qualified with const specifier. the `reference` type does. before this change, when formatting `StringPiece`, fmt 11 does not consider it as a formattable type, as it falls into the string-alike category, but its value_type is `const char` which is different from the `Char` type of the context, which is `char` when formatting using `fmt::format("{}", ipSlashCidr)`. hence we have the build failure like: ``` /usr/include/fmt/base.h: In instantiation of ‘constexpr fmt::v11::detail::value<Context> fmt::v11::detail::make_arg(T&) [with bool PACKED = true; Context = fmt::v11::context; T = folly::Range<const char*>; typename std::enable_if<PACKED, int>::type <anonymous> = 0]’: /usr/include/fmt/base.h:2002:74: required from ‘constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = context; T = {folly::Range<const char*>}; long unsigned int NUM_ARGS = 1; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 15; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]’ 2002 | return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 2003 | args)...}}; | ~~~~~ /usr/include/fmt/format.h:4357:44: required from ‘std::string fmt::v11::format(format_string<T ...>, T&& ...) [with T = {folly::Range<const char*>&}; std::string = std::__cxx11::basic_string<char>; format_string<T ...> = basic_format_string<char, folly::Range<const char*>&>]’ 4357 | return vformat(fmt, fmt::make_format_args(args...)); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ /home/kefu/folly/folly/IPAddress.cpp:100:47: required from here 100 | throw IPAddressFormatException(fmt::format( | ~~~~~~~~~~~^ 101 | "Invalid ipSlashCidr specified. Expected IP/CIDR format, got '{}'", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 102 | ipSlashCidr)); | ~~~~~~~~~~~~ /usr/include/fmt/base.h:1611:17: error: static assertion failed: Mixing character types is disallowed. 1611 | static_assert(formattable_char, "Mixing character types is disallowed."); | ^~~~~~~~~~~~~~~~ /usr/include/fmt/base.h:1611:17: note: ‘formattable_char’ evaluates to false /usr/include/fmt/base.h: In instantiation of ‘constexpr fmt::v11::detail::value<Context> fmt::v11::detail::make_arg(T&) [with bool PACKED = true; Context = fmt::v11::context; T = const folly::Range<const char*>; typename std::enable_if<PACKED, int>::type <anonymous> = 0]’: /usr/include/fmt/base.h:2002:74: required from ‘constexpr fmt::v11::detail::format_arg_store<Context, NUM_ARGS, 0, DESC> fmt::v11::make_format_args(T& ...) [with Context = context; T = {const folly::Range<const char*>}; long unsigned int NUM_ARGS = 1; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 15; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type <anonymous> = 0]’ 2002 | return {{detail::make_arg<NUM_ARGS <= detail::max_packed_args, Context>( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 2003 | args)...}}; | ~~~~~ /usr/include/fmt/format.h:4357:44: required from ‘std::string fmt::v11::format(format_string<T ...>, T&& ...) [with T = {const folly::Range<const char*>&}; std::string = std::__cxx11::basic_string<char>; format_string<T ...> = basic_format_string<char, const folly::Range<const char*>&>]’ 4357 | return vformat(fmt, fmt::make_format_args(args...)); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~ /home/kefu/folly/folly/IPAddress.cpp:113:22: required from here 113 | fmt::format("Invalid IP address {}", vec.at(0))); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/fmt/base.h:1611:17: error: static assertion failed: Mixing character types is disallowed. 1611 | static_assert(formattable_char, "Mixing character types is disallowed."); | ^~~~~~~~~~~~~~~~ /usr/include/fmt/base.h:1611:17: note: ‘formattable_char’ evaluates to false ``` in this change, we use the non-const value type, and update the some methods where the `reference` type is supposed to be used. Fixes facebook#2172 Signed-off-by: Kefu Chai <tchaikov@gmail.com>
7 tasks
@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Looks like we're going with #2265 instead |
@michel-slm thanks, i still think the |
Superseded by 21e8dcd but thanks anyway. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in general, value_type in a range-alike type should not be qualified with const specifier. the
reference
type does.before this change, when formatting
StringPiece
, fmt 11 does not consider it as a formattable type, as it falls into the string-alike category, but its value_type isconst char
which is different from theChar
type of the context, which ischar
when formatting usingfmt::format("{}", ipSlashCidr)
.hence we have the build failure like:
in this change, we use the non-const value type, and update the some methods where the
reference
type is supposed to be used.Fixes #2172
Signed-off-by: Kefu Chai tchaikov@gmail.com