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 #2210 #2211

Merged
merged 5 commits into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,13 @@ template <typename Char> class basic_string_view {
\endrst
*/
#if __cplusplus >= 201703L // C++17's char_traits::length() is constexpr.
FMT_CONSTEXPR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And another observation, it's not about this PR, just these lines in general: probably constexpr can be used here, not FMT_CONSTEXPR, since it's already under the __cplusplus >= 201703L macro check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this actually can be applied to this PR too, since it's also used in newly introduced macro definition.

constexpr
#endif
FMT_INLINE basic_string_view(const Char* s) : data_(s) {
if (std::is_same<Char, char>::value && !detail::is_constant_evaluated())
FMT_INLINE
basic_string_view(const Char* s)
: data_(s) {
Comment on lines +398 to +400
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did clang-format do this?

Copy link
Contributor

@alexezeder alexezeder Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's:

#if __cplusplus >= 201703L  // C++17's char_traits::length() is constexpr.
  FMT_CONSTEXPR
#endif
  FMT_INLINE
  basic_string_view(const Char* s) : data_(s) {

or:

#if __cplusplus >= 201703L  // C++17's char_traits::length() is constexpr.
  FMT_CONSTEXPR
#endif
  FMT_INLINE basic_string_view(const Char* s) : data_(s) {

or:

#if __cplusplus >= 201703L  // C++17's char_traits::length() is constexpr.
  constexpr
#endif
      FMT_INLINE
      basic_string_view(const Char* s)
      : data_(s) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL

if (detail::const_check(std::is_same<Char, char>::value &&
!detail::is_constant_evaluated()))
size_ = std::strlen(reinterpret_cast<const char*>(s));
else
size_ = std::char_traits<Char>::length(s);
Expand Down