diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-02-02 17:28:51 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-02-02 17:28:51 +0000 |
commit | e086e82dfe30684c9c81e2b4d570b3496c74957c (patch) | |
tree | 286e92a142652ff699325580940764b3dc554da0 | |
parent | Add -Wlogical-op (diff) | |
download | gentoobrowse-api-e086e82dfe30684c9c81e2b4d570b3496c74957c.tar.bz2 gentoobrowse-api-e086e82dfe30684c9c81e2b4d570b3496c74957c.tar.xz gentoobrowse-api-e086e82dfe30684c9c81e2b4d570b3496c74957c.zip |
Simplify packPqVar with if constexpr
-rw-r--r-- | gentoobrowse-api/domain/converters.impl.h | 21 |
1 files 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<T> & list; }; - template<typename T> - typename std::enable_if<std::is_arithmetic<T>::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<typename T> 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<std::string>(s), escapePqChar); - s << "\""; + if constexpr (std::is_arithmetic<T>::value) { + s << l; + } + else { + s << "\""; + std::transform(l.begin(), l.end(), std::ostream_iterator<std::string>(s), escapePqChar); + s << "\""; + } } template <typename T> |