From 31c37a8ee437a06b9bfda0d3ef56a755813c029d Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 27 Oct 2017 15:48:55 +0200 Subject: [PATCH] Add helper to ease disambiguation --- lib/jsonserializable.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/jsonserializable.h b/lib/jsonserializable.h index f20cf01..3850351 100644 --- a/lib/jsonserializable.h +++ b/lib/jsonserializable.h @@ -81,6 +81,23 @@ template Type JSONSerializable::fromJson(const std::string return Reflector::fromJson(json.data(), json.size()); } +/*! + * \brief Helps to disambiguate when inheritance is used. + */ +template , Type>>...> JSONSerializable &as(Type &serializable) +{ + return static_cast &>(serializable); +} + +/*! + * \brief Helps to disambiguate when inheritance is used. + */ +template , Type>>...> +const JSONSerializable &as(const Type &serializable) +{ + return static_cast &>(serializable); +} + } // namespace ReflectiveRapidJSON #endif // REFLECTIVE_RAPIDJSON_JSON_SERIALIZABLE_H