From e086e82dfe30684c9c81e2b4d570b3496c74957c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 2 Feb 2020 17:28:51 +0000 Subject: Simplify packPqVar with if constexpr --- gentoobrowse-api/domain/converters.impl.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gentoobrowse-api/domain/converters.impl.h b/gentoobrowse-api/domain/converters.impl.h index 25f9266..894d0de 100644 --- a/gentoobrowse-api/domain/converters.impl.h +++ b/gentoobrowse-api/domain/converters.impl.h @@ -22,13 +22,6 @@ namespace Slicer { std::vector & list; }; - template - typename std::enable_if::value>::type - packPqVar(std::ostream & s, const T & l) - { - s << l; - } - std::string escapePqChar(char c) { @@ -38,12 +31,18 @@ namespace Slicer { return std::string(1, c); } + template void - packPqVar(std::ostream & s, const std::string & l) + packPqVar(std::ostream & s, const T & l) { - s << "\""; - std::transform(l.begin(), l.end(), std::ostream_iterator(s), escapePqChar); - s << "\""; + if constexpr (std::is_arithmetic::value) { + s << l; + } + else { + s << "\""; + std::transform(l.begin(), l.end(), std::ostream_iterator(s), escapePqChar); + s << "\""; + } } template -- cgit v1.2.3