From fb1054a2594251f449b17b451127729a22d54fa9 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 15 Jan 2019 18:02:04 -0500 Subject: [PATCH] Fix AnyMap compilation issues with some compilers Some versions of G++ complained about being unable to decide between the const and non-const functions. Rewriting without the use of the deprecated std::mem_fun is the simplest fix. --- include/cantera/base/AnyMap.h | 4 ---- src/base/AnyMap.cpp | 22 ++++------------------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/include/cantera/base/AnyMap.h b/include/cantera/base/AnyMap.h index 3b84aa09a..f1ce0756d 100644 --- a/include/cantera/base/AnyMap.h +++ b/include/cantera/base/AnyMap.h @@ -339,10 +339,6 @@ public: void applyUnits(const UnitSystem& units); private: - template - const T& get(const std::string& key, const T& default_, - std::function getter) const; - std::unordered_map m_data; UnitSystem m_units; diff --git a/src/base/AnyMap.cpp b/src/base/AnyMap.cpp index 51116a365..82f5545bb 100644 --- a/src/base/AnyMap.cpp +++ b/src/base/AnyMap.cpp @@ -627,39 +627,25 @@ std::string AnyMap::keys_str() const return to_string(b); } -template -const T& AnyMap::get(const std::string& key, const T& default_, - std::function getter) const -{ - if (m_data.find(key) != m_data.end()) { - return getter(&m_data.at(key)); - } else { - return default_; - } -} - bool AnyMap::getBool(const std::string& key, bool default_) const { - return get(key, default_, - std::mem_fun(&AnyValue::asBool)); + return (hasKey(key)) ? m_data.at(key).asBool() : default_; } double AnyMap::getDouble(const std::string& key, double default_) const { - return get(key, default_, - std::mem_fun(&AnyValue::asDouble)); + return (hasKey(key)) ? m_data.at(key).asDouble() : default_; } long int AnyMap::getInt(const std::string& key, long int default_) const { - return get(key, default_, - std::mem_fun(&AnyValue::asInt)); + return (hasKey(key)) ? m_data.at(key).asInt() : default_; } const std::string& AnyMap::getString(const std::string& key, const std::string& default_) const { - return get(key, default_, &AnyValue::asString); + return (hasKey(key)) ? m_data.at(key).asString() : default_; } double AnyMap::convert(const std::string& key, const std::string& dest) const