Functions

map_utils.hpp File Reference

#include <map>
#include <stdexcept>
Include dependency graph for map_utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename K , typename V >
const V & map_get_value_default (const std::map< K, V > &m, const K &key, const V &val)
template<class M >
M::mapped_type at (const M &map, const typename M::key_type &key)
 Emulation for C++11's std::map::at().

Function Documentation

template<class M >
M::mapped_type at ( const M &  map,
const typename M::key_type &  key 
) [inline]

Emulation for C++11's std::map::at().

Acts like return map[key], but can be used on const map, and if the key doesn't exist will throw an exception instead of adding the key.

A non-official reference can be found here: http://en.cppreference.com/w/cpp/container/map/at

Note:
Didn't use template<class K, class V> since that has a problem when deducting the type when the key is a std::string and the type send is a charater string, e.g. "foo". Letting the map deduct the K and V types works.
Exceptions:
std::out_of_range When the key is not in the map.
Parameters:
map The map search into.
key The key to search for.
Returns:
A copy of the value of key.
Note:
C++11 uses a reference, but it's not possible to create a reference from an iterator.

Definition at line 53 of file map_utils.hpp.

Referenced by wb::move::calculate_new_route(), gui2::contains(), game_display::draw_movement_info(), terrain_filter::match_internal(), wb::recall::recall(), gui2::side_controller::show_nicks_list(), gui2::tmp_change_control::controller::show_sides_list(), gui2::sort(), and unit_weapons().

Here is the caller graph for this function:

template<typename K , typename V >
const V& map_get_value_default ( const std::map< K, V > &  m,
const K &  key,
const V &  val 
)

Definition at line 21 of file map_utils.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:08:29 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs