json_custom_base_class.hpp 883 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <type_traits> // conditional, is_same
  3. #include <nlohmann/detail/abi_macros.hpp>
  4. NLOHMANN_JSON_NAMESPACE_BEGIN
  5. namespace detail
  6. {
  7. /*!
  8. @brief Default base class of the @ref basic_json class.
  9. So that the correct implementations of the copy / move ctors / assign operators
  10. of @ref basic_json do not require complex case distinctions
  11. (no base class / custom base class used as customization point),
  12. @ref basic_json always has a base class.
  13. By default, this class is used because it is empty and thus has no effect
  14. on the behavior of @ref basic_json.
  15. */
  16. struct json_default_base {};
  17. template<class T>
  18. using json_base_class = typename std::conditional <
  19. std::is_same<T, void>::value,
  20. json_default_base,
  21. T
  22. >::type;
  23. } // namespace detail
  24. NLOHMANN_JSON_NAMESPACE_END