Merge 0469526276fc815b27692e64e2db591cc0fec126 into 2e77b9d0bf0162f178e71c14ad55140325e5349c

This commit is contained in:
Unick Soft 2021-04-10 08:14:11 -06:00 committed by GitHub
commit ee95a8b80c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,15 @@ namespace chaiscript
{
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.
/// \todo Update the Range code to base its capabilities on
@ -71,7 +80,14 @@ namespace chaiscript
{
throw std::range_error("Range empty");
}
--m_end;
if constexpr (!isUnorderedMap<typename std::decay<Container>::type>::value)
{
--m_end;
}
else
{
throw std::range_error("Cannot call pop_back for unordered_map");
}
}
decltype(auto) front() const
@ -90,7 +106,14 @@ namespace chaiscript
throw std::range_error("Range empty");
}
auto pos = m_end;
--pos;
if constexpr (!isUnorderedMap<typename std::decay<Container>::type>::value)
{
--pos;
}
else
{
throw std::range_error("Cannot call back for unordered_map");
}
return (*(pos));
}