Fix member initialization order warning in auto_parser

The compiler was warning about member initialization order mismatch.
C++ initializes members in the order they are declared in the class,
not the order they appear in the initializer list.

Fixed by reordering member declarations to match the initialization
order needed: m_doc must be initialized before m_parser since we
need to call parser.iterate() before moving the parser.

This fixes the -Werror=reorder compilation error in CI.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Francisco Geiman Thiesen
2025-08-03 18:48:07 +00:00
parent a7c95e9cc8
commit 9fbc577be7
4 changed files with 10 additions and 10 deletions
+4 -4
View File
@@ -86,8 +86,8 @@ struct [[nodiscard]] auto_parser
using const_iterator = auto_iterator; // auto_iterator is already const
private:
ParserType m_parser;
ondemand::document m_doc;
ParserType m_parser;
// Caching the iterator here:
iterator::auto_iterator_storage iter_storage{};
@@ -101,7 +101,7 @@ public:
// non-pointer constructors:
explicit auto_parser(ParserType &&parser, ondemand::document &&doc) noexcept
requires(!std::is_pointer_v<ParserType>)
: m_parser{std::move(parser)}, m_doc{std::move(doc)} {}
: m_doc{std::move(doc)}, m_parser{std::move(parser)} {}
explicit auto_parser(ParserType &&parser,
padded_string_view const str) noexcept
@@ -117,12 +117,12 @@ public:
explicit auto_parser(std::remove_pointer_t<ParserType> &parser,
ondemand::document &&doc) noexcept
requires(std::is_pointer_v<ParserType>)
: m_parser{&parser}, m_doc{std::move(doc)} {}
: m_doc{std::move(doc)}, m_parser{&parser} {}
explicit auto_parser(std::remove_pointer_t<ParserType> &parser,
padded_string_view const str) noexcept
requires(std::is_pointer_v<ParserType>)
: m_parser{&parser}, m_doc(parser.iterate(str)) {}
: m_doc(parser.iterate(str)), m_parser{&parser} {}
explicit auto_parser(ParserType parser, ondemand::document &&doc) noexcept
requires(std::is_pointer_v<ParserType>)
+1 -1
View File
@@ -1,4 +1,4 @@
/* auto-generated on 2025-08-03 18:12:50 +0000. Do not edit! */
/* auto-generated on 2025-08-03 18:36:14 +0000. Do not edit! */
/* including simdjson.cpp: */
/* begin file simdjson.cpp */
#define SIMDJSON_SRC_SIMDJSON_CPP
+5 -5
View File
@@ -1,4 +1,4 @@
/* auto-generated on 2025-08-03 18:12:50 +0000. Do not edit! */
/* auto-generated on 2025-08-03 18:36:14 +0000. Do not edit! */
/* including simdjson.h: */
/* begin file simdjson.h */
#ifndef SIMDJSON_H
@@ -135338,8 +135338,8 @@ struct [[nodiscard]] auto_parser
using const_iterator = auto_iterator; // auto_iterator is already const
private:
ParserType m_parser;
ondemand::document m_doc;
ParserType m_parser;
// Caching the iterator here:
iterator::auto_iterator_storage iter_storage{};
@@ -135353,7 +135353,7 @@ public:
// non-pointer constructors:
explicit auto_parser(ParserType &&parser, ondemand::document &&doc) noexcept
requires(!std::is_pointer_v<ParserType>)
: m_parser{std::move(parser)}, m_doc{std::move(doc)} {}
: m_doc{std::move(doc)}, m_parser{std::move(parser)} {}
explicit auto_parser(ParserType &&parser,
padded_string_view const str) noexcept
@@ -135369,12 +135369,12 @@ public:
explicit auto_parser(std::remove_pointer_t<ParserType> &parser,
ondemand::document &&doc) noexcept
requires(std::is_pointer_v<ParserType>)
: m_parser{&parser}, m_doc{std::move(doc)} {}
: m_doc{std::move(doc)}, m_parser{&parser} {}
explicit auto_parser(std::remove_pointer_t<ParserType> &parser,
padded_string_view const str) noexcept
requires(std::is_pointer_v<ParserType>)
: m_parser{&parser}, m_doc(parser.iterate(str)) {}
: m_doc(parser.iterate(str)), m_parser{&parser} {}
explicit auto_parser(ParserType parser, ondemand::document &&doc) noexcept
requires(std::is_pointer_v<ParserType>)
Binary file not shown.