4#include <boost/optional.hpp> 
    6#ifdef ROSE_ENABLE_BOOST_SERIALIZATION 
    7#include <boost/serialization/access.hpp> 
    8#include <boost/serialization/nvp.hpp> 
   15template<
class Key, 
class T, 
class Compare=std::less<Key>, 
class Alloc=std::allocator<std::pair<const Key, T> > >
 
   16class Map: 
public std::map<Key, T, Compare, Alloc> {
 
   18    typedef std::map<Key, T, Compare, Alloc> map_type;
 
   20#ifdef ROSE_ENABLE_BOOST_SERIALIZATION 
   22    friend class boost::serialization::access;
 
   25    void serialize(S &s, 
const unsigned ) {
 
   26        s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(map_type);
 
   34    explicit Map(
const Compare& comp, 
const Alloc& alloc = Alloc())
 
   35        : map_type(comp, alloc) {}
 
   37    template <
class InputIterator>
 
   38    Map(InputIterator first, InputIterator last, 
const Compare& comp = Compare(), 
const Alloc& alloc = Alloc())
 
   39        : map_type(first, last, comp, alloc) {};
 
   44    Map& operator=(
const Map&) = 
default;
 
   57    boost::optional<T> 
get(
const Key &key)
 const {
 
   58        typename map_type::const_iterator found = this->find(key);
 
   59        return found==this->end() ? boost::optional<T>() : boost::optional<T>(found->second);
 
 
   67        typename map_type::const_iterator found = this->find(key);
 
   68        if (found==this->end())
 
   69            throw std::domain_error(
"key not present in map");
 
 
   73        typename map_type::iterator found = this->find(key);
 
   74        if (found==this->end())
 
   75            throw std::domain_error(
"key not present in map");
 
 
   84        typename map_type::const_iterator found = this->find(key);
 
   85        return found==this->end() ? dflt : found->second;
 
 
   88        typename map_type::iterator found = this->find(key);
 
   89        return found==this->end() ? dflt : found->second;
 
 
   97    bool exists(
const Key &key)
 const { 
return this->find(key)!=this->end(); }
 
 
Extends std::map with methods that return optional values.
 
const T & get_value_or(const Key &key, const T &dflt) const
Convenience for getting a value from an Option.
 
bool exists(const Key &key) const
Convenience for determining if a key exists in this map.
 
boost::optional< T > get(const Key &key) const
Lookup and return a value or nothing.
 
T & get_value_or(const Key &key, T &dflt)
Convenience for getting a value from an Option.
 
T & get_one(const Key &key)
Look up one value or throw an exception.
 
const T & get_one(const Key &key) const
Look up one value or throw an exception.