diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-02-05 23:37:21 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-02-05 23:37:21 +0000 |
commit | 63b49d3ff0a955c894cde296958fd54708913bea (patch) | |
tree | 868db69f24c50619d170c885124f4ca8a5d18a7d | |
parent | Remove unrequired defaulted function (diff) | |
download | libdbpp-63b49d3ff0a955c894cde296958fd54708913bea.tar.bz2 libdbpp-63b49d3ff0a955c894cde296958fd54708913bea.tar.xz libdbpp-63b49d3ff0a955c894cde296958fd54708913bea.zip |
Skip lexical cast if naturally convertible
-rw-r--r-- | libdbpp/command.h | 10 |
1 files 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<typename X> 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<X>(i->second); + if (auto i = map.find(key); i != map.end()) { + if constexpr (std::is_convertible<CommandOptionsMap::mapped_type, X>::value) { + return i->second; + } + else { + return boost::lexical_cast<X>(i->second); + } } return def; } |