Skip to content

Commit b9528b7

Browse files
Address code reviews.
1 parent 52f1a11 commit b9528b7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

antithesis_sdk.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ namespace antithesis {
3434
};
3535

3636
struct JSON; struct JSONArray;
37-
typedef std::variant<std::nullptr_t, std::string, bool, char, int, uint64_t, float, double, const char*, JSON, JSONArray> JSONValue;
37+
typedef std::variant<JSON, std::nullptr_t, std::string, bool, char, int, uint64_t, float, double, const char*, JSONArray> JSONValue;
3838

3939
struct JSONArray : std::vector<JSONValue> {
4040
using std::vector<JSONValue>::vector;
4141

42-
template<typename T> requires std::convertible_to<T, JSONValue>
42+
template<typename T, std::enable_if_t<std::is_convertible_v<T, JSONValue>, bool> = true>
4343
JSONArray(std::vector<T> vals) : std::vector<JSONValue>(vals.begin(), vals.end()) {}
4444
};
4545

4646
struct JSON : std::map<std::string, JSONValue> {
47+
JSON() : std::map<std::string, JSONValue>() {}
4748
JSON( std::initializer_list<std::pair<const std::string, JSONValue>> args) : std::map<std::string, JSONValue>(args) {}
4849

4950
JSON( std::initializer_list<std::pair<const std::string, JSONValue>> args, std::vector<std::pair<const std::string, JSONValue>> more_args ) : std::map<std::string, JSONValue>(args) {
@@ -299,7 +300,7 @@ namespace antithesis {
299300
bool first = true;
300301
for (auto &item : arg) {
301302
if (!first) {
302-
out << ", ";
303+
out << ',';
303304
}
304305
first = false;
305306
out << item;
@@ -314,18 +315,18 @@ namespace antithesis {
314315
}
315316

316317
static std::ostream& operator<<(std::ostream& out, const JSON& details) {
317-
out << "{ ";
318+
out << '{';
318319

319320
bool first = true;
320321
for (auto [key, value] : details) {
321322
if (!first) {
322-
out << ", ";
323+
out << ',';
323324
}
324-
out << std::quoted(key) << ": " << value;
325+
out << std::quoted(key) << ':' << value;
325326
first = false;
326327
}
327328

328-
out << " }";
329+
out << '}';
329330
return out;
330331
}
331332

0 commit comments

Comments
 (0)