diff --git a/dune/xt/common/fixed_map.hh b/dune/xt/common/fixed_map.hh index d2bdbd7aad387cc097e4b9c935aca72bffef8943..ebf9e95849cab8038f16bd13a3e7501ce28e8b7a 100644 --- a/dune/xt/common/fixed_map.hh +++ b/dune/xt/common/fixed_map.hh @@ -126,30 +126,19 @@ private: typedef FixedMap<key_imp, T, nin> ThisType; - template <class K> // for sfinae to work this needs to be a template although the type is already fixed - typename std::enable_if<std::is_convertible<K, std::string>::value, std::string>::type - range_error_message(K key) const + std::string range_error_message(key_imp key) const { std::stringstream ss; - ss << "missing key '" << key << "' in FixedMap!"; - return ss.str(); - } - - template <class K> - typename std::enable_if<std::is_convertible<K, int>::value, std::string>::type range_error_message(K key) const - { - std::stringstream ss; - ss << "missing key (converted to int)'" << int(key) << "' in FixedMap!"; + if constexpr (std::is_convertible<key_imp, std::string>::value) { + ss << "missing key '" << key << "' in FixedMap!"; + } else if constexpr (std::is_convertible<key_imp, int>::value) { + ss << "missing key (converted to int)'" << int(key) << "' in FixedMap!"; + } else { + ss << "missing key is not printable"; + } return ss.str(); } - template <class K> - typename std::enable_if<!(std::is_convertible<K, int>::value || std::is_convertible<K, std::string>::value), - std::string>::type range_error_message(K /*key*/) const - { - return "missing key is not printable"; - } - public: typedef key_imp key_type; typedef T mapped_type;