File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -422,11 +422,17 @@ template <typename Char> class basic_string_view {
422
422
*/
423
423
FMT_CONSTEXPR_CHAR_TRAITS
424
424
FMT_INLINE
425
- basic_string_view (const Char* s) : data_(s) {
425
+ basic_string_view (const Char* s) : data_(s), size_(0 ) {
426
+ // This test is needed to ensure that this constructor is constexpr in C++17
427
+ // modes.
428
+ #ifdef __cpp_lib_is_constant_evaluated
426
429
if (detail::const_check (std::is_same<Char, char >::value &&
427
- !detail::is_constant_evaluated ()))
430
+ !detail::is_constant_evaluated ())) {
431
+ // Call strlen directly for better code generation in non-optimized
432
+ // builds.
428
433
size_ = std::strlen (reinterpret_cast <const char *>(s));
429
- else
434
+ } else
435
+ #endif
430
436
size_ = std::char_traits<Char>::length (s);
431
437
}
432
438
You can’t perform that action at this time.
0 commit comments