forked from boostorg/unordered
Test, implement and document 'at'.
[SVN r41125]
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
|
||||
@@ -1839,6 +1839,17 @@ namespace boost {
|
||||
return this->end();
|
||||
}
|
||||
|
||||
value_type& at(key_type const& k) const
|
||||
{
|
||||
bucket_ptr bucket = get_bucket(k);
|
||||
local_iterator_base it = find_iterator(bucket, k);
|
||||
|
||||
if (it.not_finished())
|
||||
return *it;
|
||||
else
|
||||
throw std::out_of_range("Unable to find key in unordered_map.");
|
||||
}
|
||||
|
||||
// equal_range
|
||||
//
|
||||
// strong exception safety, no side effects
|
||||
|
||||
@@ -211,6 +211,16 @@ namespace boost
|
||||
return base[k].second;
|
||||
}
|
||||
|
||||
mapped_type& at(const key_type& k)
|
||||
{
|
||||
return base.at(k).second;
|
||||
}
|
||||
|
||||
mapped_type const& at(const key_type& k) const
|
||||
{
|
||||
return base.at(k).second;
|
||||
}
|
||||
|
||||
// lookup
|
||||
|
||||
iterator find(const key_type& k)
|
||||
|
||||
Reference in New Issue
Block a user