Util: Move json/conversion.h -> meta/odr.h
This commit is contained in:
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 Riyyi
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef JSON_CONVERSION_H
|
|
||||||
#define JSON_CONVERSION_H
|
|
||||||
|
|
||||||
namespace Json {
|
|
||||||
|
|
||||||
namespace Detail {
|
|
||||||
|
|
||||||
// Avoid ODR (One Definition Rule) violations
|
|
||||||
template<typename T>
|
|
||||||
constexpr T staticConst {};
|
|
||||||
|
|
||||||
} // namespace Detail
|
|
||||||
|
|
||||||
} // namespace Json
|
|
||||||
|
|
||||||
#endif // JSON_CONVERSION_H
|
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "util/json/array.h"
|
#include "util/json/array.h"
|
||||||
#include "util/json/conversion.h"
|
|
||||||
#include "util/json/object.h"
|
#include "util/json/object.h"
|
||||||
|
#include "util/meta/odr.h"
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ struct fromJsonFunction {
|
|||||||
// Anonymous namespace prevents multiple definition of the reference
|
// Anonymous namespace prevents multiple definition of the reference
|
||||||
namespace {
|
namespace {
|
||||||
// Function object
|
// Function object
|
||||||
constexpr const auto& fromJson = Detail::staticConst<Detail::fromJsonFunction>; // NOLINT (misc-definitions-in-headers)
|
constexpr const auto& fromJson = Util::Detail::staticConst<Detail::fromJsonFunction>; // NOLINT(misc-definitions-in-headers,clang-diagnostic-unused-variable)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace Json
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
#include <utility> // forward
|
#include <utility> // forward
|
||||||
|
|
||||||
#include "util/json/array.h"
|
#include "util/json/array.h"
|
||||||
#include "util/json/conversion.h"
|
|
||||||
#include "util/json/object.h"
|
#include "util/json/object.h"
|
||||||
|
#include "util/meta/odr.h"
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ struct toJsonFunction {
|
|||||||
// Anonymous namespace prevents multiple definition of the reference
|
// Anonymous namespace prevents multiple definition of the reference
|
||||||
namespace {
|
namespace {
|
||||||
// Function object
|
// Function object
|
||||||
constexpr const auto& toJson = Detail::staticConst<Detail::toJsonFunction>; // NOLINT (misc-definitions-in-headers)
|
constexpr const auto& toJson = Util::Detail::staticConst<Detail::toJsonFunction>; // NOLINT(misc-definitions-in-headers,clang-diagnostic-unused-variable)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace Json
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Riyyi
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_ODR_H
|
||||||
|
#define META_ODR_H
|
||||||
|
|
||||||
|
namespace Util {
|
||||||
|
|
||||||
|
namespace Detail {
|
||||||
|
|
||||||
|
// Avoid ODR (One Definition Rule) violations,
|
||||||
|
// variable templates are required to have external linkage
|
||||||
|
template<typename T>
|
||||||
|
constexpr T staticConst {};
|
||||||
|
|
||||||
|
} // namespace Detail
|
||||||
|
|
||||||
|
} // namespace Util
|
||||||
|
|
||||||
|
#endif // META_ODR_H
|
||||||
Reference in New Issue
Block a user