diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index bc3c0869..9d63aeba 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -37,6 +37,15 @@ namespace chaiscript { namespace standard_library { + template + struct isUnorderedMap { + static constexpr bool value = false; + }; + + template + struct isUnorderedMap> { + 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::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::type>::value) + { + --pos; + } + else + { + throw std::range_error("Cannot call back for unordered_map"); + } return (*(pos)); }