mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-02-05 17:30:07 +08:00
Merge 0469526276fc815b27692e64e2db591cc0fec126 into 2e77b9d0bf0162f178e71c14ad55140325e5349c
This commit is contained in:
commit
ee95a8b80c
@ -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,7 +80,14 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
throw std::range_error("Range empty");
|
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
|
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;
|
||||||
--pos;
|
if constexpr (!isUnorderedMap<typename std::decay<Container>::type>::value)
|
||||||
|
{
|
||||||
|
--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