-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,11 +314,13 @@ FMT_BEGIN_DETAIL_NAMESPACE | |
// (void)var does not work on many Intel compilers. | ||
template <typename... T> FMT_CONSTEXPR void ignore_unused(const T&...) {} | ||
|
||
constexpr FMT_INLINE auto is_constant_evaluated() FMT_NOEXCEPT -> bool { | ||
constexpr FMT_INLINE auto is_constant_evaluated(bool default_value = false) | ||
FMT_NOEXCEPT -> bool { | ||
#ifdef __cpp_lib_is_constant_evaluated | ||
ignore_unused(default_value); | ||
return std::is_constant_evaluated(); | ||
#else | ||
return false; | ||
return default_value; | ||
#endif | ||
} | ||
|
||
|
@@ -426,7 +428,7 @@ template <typename Char> class basic_string_view { | |
FMT_INLINE | ||
basic_string_view(const Char* s) : data_(s) { | ||
if (detail::const_check(std::is_same<Char, char>::value && | ||
!detail::is_constant_evaluated())) | ||
!detail::is_constant_evaluated(true))) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vitaut
Author
Contributor
|
||
size_ = std::strlen(reinterpret_cast<const char*>(s)); | ||
else | ||
size_ = std::char_traits<Char>::length(s); | ||
|
@vitaut,
But this condition is always false until C++20. And debug mode code generation optimizations don't work until C++20.
It might be worth removing this check and switch to use
std::char_traits<Char>::length
? Or I'm wrong?