Skip to content
Snippets Groups Projects
Commit 3eb4506e authored by René Fritze's avatar René Fritze Committed by René Fritze
Browse files

[fixed_map] simplify range_error_message

parent b2b4ca26
No related branches found
No related tags found
1 merge request!31Sfinae and stuff
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment