Skip to content

Commit 10279e4

Browse files
committed
fix: use literal true/false constants for bool conversion
- nlohmann_json 3.12 can construct from literal true/false - Use ternary operator to select between json(true) and json(false) - Works around the explicit bool constructor restriction
1 parent 95b3ac9 commit 10279e4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/v2/pdf_resources/page_cell.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ namespace pdflib
186186
cell.push_back(font_name); // 18
187187

188188
// Work around nlohmann_json 3.12 explicit bool constructor
189-
// Use brace initialization to explicitly construct from bool
190-
cell.push_back(nlohmann::json{widget}); // 19
191-
cell.push_back(nlohmann::json{left_to_right}); // 20
189+
// Must use ternary to select pre-constructed boolean values
190+
cell.push_back(widget ? nlohmann::json(true) : nlohmann::json(false)); // 19
191+
cell.push_back(left_to_right ? nlohmann::json(true) : nlohmann::json(false)); // 20
192192
}
193193
assert(cell.size()==header.size());
194194

src/v2/pdf_sanitators/cells.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ namespace pdflib
124124
item["rendering_mode"] = cell.rendering_mode;
125125

126126
// Work around nlohmann_json 3.12 explicit bool constructor
127-
item["widget"] = nlohmann::json{cell.widget};
128-
item["left_to_right"] = nlohmann::json{cell.left_to_right};
127+
item["widget"] = cell.widget ? nlohmann::json(true) : nlohmann::json(false);
128+
item["left_to_right"] = cell.left_to_right ? nlohmann::json(true) : nlohmann::json(false);
129129
}
130130

131131
result.push_back(item);

src/v2/qpdf/to_json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ namespace pdflib
163163
{
164164
bool val = obj.getBoolValue();
165165
// Work around nlohmann_json 3.12 explicit bool constructor
166-
// Use brace initialization to explicitly construct from bool
167-
result = nlohmann::json{val};
166+
// Must use ternary to select pre-constructed boolean values
167+
result = val ? nlohmann::json(true) : nlohmann::json(false);
168168
}
169169
else
170170
{

0 commit comments

Comments
 (0)