From 5c95288874918ddf6f6900a230eba80720773ae2 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Sun, 10 Jul 2022 00:30:31 +0200 Subject: [PATCH] Util: Move staticConst to separate header --- src/util/json/conversion.h | 22 ++++++++++++++++++++++ src/util/json/fromjson.h | 6 ++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/util/json/conversion.h diff --git a/src/util/json/conversion.h b/src/util/json/conversion.h new file mode 100644 index 0000000..7f27cd8 --- /dev/null +++ b/src/util/json/conversion.h @@ -0,0 +1,22 @@ +/* + * 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 +constexpr T staticConst {}; + +} // namespace Detail + +} // namespace Json + +#endif // JSON_CONVERSION_H diff --git a/src/util/json/fromjson.h b/src/util/json/fromjson.h index 048faf2..410d094 100644 --- a/src/util/json/fromjson.h +++ b/src/util/json/fromjson.h @@ -13,9 +13,11 @@ #include #include #include +#include // forward #include #include "util/json/array.h" +#include "util/json/conversion.h" #include "util/json/object.h" namespace Json { @@ -86,10 +88,6 @@ struct fromJsonFunction { } }; -// Avoid ODR (One Definition Rule) violations -template -constexpr T staticConst {}; - } // namespace Detail // Anonymous namespace prevents multiple definition of the reference