From dbc78d185c4bafe03b458f9eeb7ef3af35ce2eb2 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Tue, 21 Jun 2022 07:33:43 +0200 Subject: 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. --- lib/events/single_key_value.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/events') 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 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 -- cgit v1.2.3