-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to add a custom base class as an extension point to json nodes
* by default an empty class is used and the library behaves as it already did * if a user explicitly adds a base class (last template parameter) each node inherits it * this can be used to add custom extensions (e.g. add metadata / visitor methods) * add test for this feature
- Loading branch information
Showing
6 changed files
with
410 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
namespace nlohmann | ||
{ | ||
namespace detail | ||
{ | ||
|
||
struct json_default_base {}; | ||
|
||
template<class T> | ||
using json_base_class = typename std::conditional< | ||
std::is_same<T, void>::value, | ||
json_default_base, | ||
T | ||
>::type; | ||
|
||
} // namespace detail | ||
} // namespace nlohmann |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.