Skip to content

Commit 2b2444c

Browse files
committed
fix: make nested_formatter constexpr default constructible
1 parent cd9b36d commit 2b2444c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

include/fmt/format.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -4218,12 +4218,18 @@ struct formatter<nested_view<T>> {
42184218
template <typename T>
42194219
struct nested_formatter {
42204220
private:
4221-
int width_;
4221+
int width_ = 0;
42224222
detail::fill_t<char> fill_;
42234223
align_t align_ : 4;
42244224
formatter<T> formatter_;
42254225

42264226
public:
4227+
// Using initialization list for 'align_' because default member initializers
4228+
// for bit-fields are C++20
4229+
constexpr nested_formatter() noexcept(
4230+
std::is_nothrow_constructible<formatter<T>>::value)
4231+
: align_(align_t::none) {}
4232+
42274233
FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> const char* {
42284234
auto specs = detail::dynamic_format_specs<char>();
42294235
auto it = parse_format_specs(

0 commit comments

Comments
 (0)