mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 11:28:20 +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_INLINE
|
||||
basic_string_view(const Char* s) : data_(s) {
|
||||
if (detail::const_check(std::is_same<Char, char>::value &&
|
||||
!detail::is_constant_evaluated(true)))
|
||||
size_ = std::strlen(reinterpret_cast<const char*>(s));
|
||||
else
|
||||
size_ = std::char_traits<Char>::length(s);
|
||||
}
|
||||
basic_string_view(const Char* s)
|
||||
: data_(s),
|
||||
size_(detail::const_check(std::is_same<Char, char>::value &&
|
||||
!detail::is_constant_evaluated(true))
|
||||
? std::strlen(reinterpret_cast<const char*>(s))
|
||||
: std::char_traits<Char>::length(s)) {}
|
||||
|
||||
/** Constructs a string reference from a ``std::basic_string`` object. */
|
||||
template <typename Traits, typename Alloc>
|
||||
|
@ -2109,8 +2109,7 @@ FMT_CONSTEXPR_CHAR_TRAITS auto write(OutputIt out, const Char* value)
|
||||
if (!value) {
|
||||
throw_format_error("string pointer is null");
|
||||
} else {
|
||||
auto length = std::char_traits<Char>::length(value);
|
||||
out = write(out, basic_string_view<Char>(value, length));
|
||||
out = write(out, basic_string_view<Char>(value));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user