From 63b49d3ff0a955c894cde296958fd54708913bea Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 5 Feb 2019 23:37:21 +0000 Subject: Skip lexical cast if naturally convertible --- libdbpp/command.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libdbpp/command.h b/libdbpp/command.h index f200d69..ce003c9 100644 --- a/libdbpp/command.h +++ b/libdbpp/command.h @@ -41,9 +41,13 @@ namespace DB { template static X get(const CommandOptionsMap & map, const std::string & key, const X & def) { - auto i = map.find(key); - if (i != map.end()) { - return boost::lexical_cast(i->second); + if (auto i = map.find(key); i != map.end()) { + if constexpr (std::is_convertible::value) { + return i->second; + } + else { + return boost::lexical_cast(i->second); + } } return def; } -- cgit v1.2.3