aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-06-21 07:33:43 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-04 18:42:11 +0200
commitdbc78d185c4bafe03b458f9eeb7ef3af35ce2eb2 (patch)
treee6c060c4c15e633df344f18fd8af366c06175ba0
parent8cb629f406f5b8b1ff7ce787dd3967d5684e07c3 (diff)
downloadlibquotient-dbc78d185c4bafe03b458f9eeb7ef3af35ce2eb2.tar.gz
libquotient-dbc78d185c4bafe03b458f9eeb7ef3af35ce2eb2.zip
SingleKeyValue: allow seamless construction from the underlying type
SingleKeyValue is a tiny wrapper and supposed to be discreet. Having to explicitly (even if only with braces) construct its objects stands in the way of readability on the consuming side of the code and sometimes prevents direct initialisation of event objects without constructors getting some kind of ContentParamTs parameter pack where a single content_type argument would suffice otherwise.
-rw-r--r--lib/events/single_key_value.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/events/single_key_value.h b/lib/events/single_key_value.h
index 75ca8cd2..5edff3b1 100644
--- a/lib/events/single_key_value.h
+++ b/lib/events/single_key_value.h
@@ -7,6 +7,15 @@ namespace Quotient {
namespace EventContent {
template <typename T, const QLatin1String* KeyStr>
struct SingleKeyValue {
+ // NOLINTBEGIN(google-explicit-constructor): that check should learn
+ // about explicit(false)
+ QUO_IMPLICIT SingleKeyValue(const T& v = {})
+ : value { v }
+ {}
+ QUO_IMPLICIT SingleKeyValue(T&& v)
+ : value { std::move(v) }
+ {}
+ // NOLINTEND(google-explicit-constructor)
T value;
};
} // namespace EventContent