mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-04 23:30:05 +00:00
Move size_ initialization to initializer list (#2529)
This commit is contained in:
parent
012cc709d0
commit
0a985fd4c6
@ -433,13 +433,12 @@ template <typename Char> class basic_string_view {
|
|||||||
*/
|
*/
|
||||||
FMT_CONSTEXPR_CHAR_TRAITS
|
FMT_CONSTEXPR_CHAR_TRAITS
|
||||||
FMT_INLINE
|
FMT_INLINE
|
||||||
basic_string_view(const Char* s) : data_(s) {
|
basic_string_view(const Char* s)
|
||||||
if (detail::const_check(std::is_same<Char, char>::value &&
|
: data_(s),
|
||||||
!detail::is_constant_evaluated(true)))
|
size_(detail::const_check(std::is_same<Char, char>::value &&
|
||||||
size_ = std::strlen(reinterpret_cast<const char*>(s));
|
!detail::is_constant_evaluated(true))
|
||||||
else
|
? std::strlen(reinterpret_cast<const char*>(s))
|
||||||
size_ = std::char_traits<Char>::length(s);
|
: std::char_traits<Char>::length(s)) {}
|
||||||
}
|
|
||||||
|
|
||||||
/** Constructs a string reference from a ``std::basic_string`` object. */
|
/** Constructs a string reference from a ``std::basic_string`` object. */
|
||||||
template <typename Traits, typename Alloc>
|
template <typename Traits, typename Alloc>
|
||||||
|
@ -2109,8 +2109,7 @@ FMT_CONSTEXPR_CHAR_TRAITS auto write(OutputIt out, const Char* value)
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
throw_format_error("string pointer is null");
|
throw_format_error("string pointer is null");
|
||||||
} else {
|
} else {
|
||||||
auto length = std::char_traits<Char>::length(value);
|
out = write(out, basic_string_view<Char>(value));
|
||||||
out = write(out, basic_string_view<Char>(value, length));
|
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user