From 3555371a7dbe41bc7838f4a04a41427dfe042a84 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 19 Nov 2015 10:41:58 +0200 Subject: [PATCH] Add valueOrEmpty --- pdns/misc.hh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pdns/misc.hh b/pdns/misc.hh index eea3b4a9a..6bad9151e 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -636,3 +636,9 @@ const T& defTer(const T& a, const T& b) { return a ? a : b; } + +template +T valueOrEmpty(const P val) { + if (!val) return T{}; + return T(val); +} -- 2.40.0