Skip to content

Conversation

@trueqbit
Copy link
Contributor

This PR brings the following updates:

  • CMake
    • Ability to set a C++ Standard mode from CMake with a default fallback to C++17.
    • Instruct Visual Studio to create a header-only library project with preserved directory structure.
  • C++ feature detection
    • Centralized (internal) configuration header that is made available at the very beginning of the main json.h header file. It is located in a subfolder called “functional” because it provides functional elements internal to cpp-json.
    • Check for C++17 core language features that cpp-json depends on, bailing out with a hard error if not met.
    • This approach makes it easy to use new C++ features and to require a future C++ Standard.
  • Code quality
    • Marked converting constructors with explicit(false). Some code analysis standards like MISRA require to be explicit about it.
    • json::value can use the default copy/move constructors and assignment operators.
    • Renamed JSON_THROW -> CPP_JSON_THROW to avoid potential naming conflicts.
  • Code modernization
    • Static call operator for lambdas.
    • Use std::*_t alias templates and std::*_v variable templates everywhere.
@@ -0,0 +1,11 @@
#pragma once
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's ubiquitous, but I do tend to avoid #pragma once since it's non-standard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I find this quite stringent, as all compilers support it. However, I respect your decision.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would then also rename the header guards from JSON_* -> CPP_JSON_* to be as independent as possible with regard to name clashes. Is that alright?


public:
parser(std::string_view s)
CPP_JSON_EXPLICIT_IF(false) parser(std::string_view s)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually make this constructor plain old explicit.

@eteran
Copy link
Owner

eteran commented Nov 16, 2025

Only a couple of nit-picks this time ;-) Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants