@@ -23,7 +23,7 @@ SOFTWARE.
2323*/
2424
2525// Important note: the types in this file are only intended for compile-time construction
26- // but consteval doesn't exist in C++17
26+ // but consteval doesn't exist in C++17, and we're targeting C++17
2727
2828#ifndef CONSTEXPR_JSON_HPP_INCLUDED
2929#define CONSTEXPR_JSON_HPP_INCLUDED
@@ -34,13 +34,15 @@ SOFTWARE.
3434#include < stdexcept>
3535#include < string_view>
3636
37+ // simple pair to speed up compilation a bit compared to std::pair
3738namespace json2cpp {
3839template <typename First, typename Second> struct pair
3940{
4041 First first;
4142 Second second;
4243};
4344
45+ // simple span because std::span is not in C++17
4446template <typename T> struct span
4547{
4648 template <std::size_t Size>
@@ -388,6 +390,8 @@ template<typename CharType> struct basic_json
388390
389391 template <typename Type>[[nodiscard]] constexpr auto get () const
390392 {
393+ // I don't like this level of implicit conversions in the `get()` function,
394+ // but it's necessary for API compatibility with nlohmann::json
391395 if constexpr (std::is_same_v<Type, std::uint64_t > || std::is_same_v<Type, std::int64_t > || std::is_same_v<Type, double >) {
392396 if (const auto *uint_value = data.get_if_uinteger (); uint_value != nullptr ) {
393397 return Type (*uint_value);
@@ -396,8 +400,6 @@ template<typename CharType> struct basic_json
396400 } else if (const auto *fpvalue = data.get_if_floating_point (); fpvalue != nullptr ) {
397401 return Type (*fpvalue);
398402 } else {
399- // std::stringstream ss;
400- // ss << is_string() << is_object() << is_array() << is_string() << is_boolean() << is_structured() << is_number() << is_null() << is_binary() << is_primitive();
401403 throw std::runtime_error (" Unexpected type: number requested" );// + ss.str() );
402404 }
403405 } else if constexpr (std::is_same_v<Type,
0 commit comments