Test, implement and document 'at'.

[SVN r41125]
This commit is contained in:
Daniel James
2007-11-16 00:31:12 +00:00
parent 7da16a62a4
commit f0c62d3f0f
7 changed files with 77 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
#include <cmath>
#include <algorithm>
#include <utility>
#include <stdexcept>
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_categories.hpp>

View File

@@ -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

View File

@@ -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)