mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
Fix compilation error for case when we use std::unordered_map inside map_type for g++ or Mac. Fix should work for C++17. For example: bootstrap::standard_library::map_type<std::unordered_map<std::string, int>>("StringInt_Map")
This commit is contained in:
parent
2e77b9d0bf
commit
0469526276
@ -37,6 +37,15 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
namespace standard_library
|
namespace standard_library
|
||||||
{
|
{
|
||||||
|
template <class T>
|
||||||
|
struct isUnorderedMap {
|
||||||
|
static constexpr bool value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Key,class Value>
|
||||||
|
struct isUnorderedMap<std::unordered_map<Key,Value>> {
|
||||||
|
static constexpr bool value = true;
|
||||||
|
};
|
||||||
|
|
||||||
/// Bidir_Range, based on the D concept of ranges.
|
/// Bidir_Range, based on the D concept of ranges.
|
||||||
/// \todo Update the Range code to base its capabilities on
|
/// \todo Update the Range code to base its capabilities on
|
||||||
@ -71,8 +80,15 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
throw std::range_error("Range empty");
|
throw std::range_error("Range empty");
|
||||||
}
|
}
|
||||||
|
if constexpr (!isUnorderedMap<typename std::decay<Container>::type>::value)
|
||||||
|
{
|
||||||
--m_end;
|
--m_end;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::range_error("Cannot call pop_back for unordered_map");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
decltype(auto) front() const
|
decltype(auto) front() const
|
||||||
{
|
{
|
||||||
@ -90,7 +106,14 @@ namespace chaiscript
|
|||||||
throw std::range_error("Range empty");
|
throw std::range_error("Range empty");
|
||||||
}
|
}
|
||||||
auto pos = m_end;
|
auto pos = m_end;
|
||||||
|
if constexpr (!isUnorderedMap<typename std::decay<Container>::type>::value)
|
||||||
|
{
|
||||||
--pos;
|
--pos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw std::range_error("Cannot call back for unordered_map");
|
||||||
|
}
|
||||||
return (*(pos));
|
return (*(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user