bobah bobah - 1 year ago 82
C++ Question

Why no transparent C++1x std::map::at?

Is there a reason for missing transparent (

template <class K> at(K&& key);
) in

Answer Source

My guess is that std::map::at() must be a "bounds-checked" version of std::map::operator[](). Providing a transparent version of std::map::operator[]() imposes an additional requirement on std::map::key_type and the query key type K - if the query key is not in the map, it must be inserted (with default constructed value), which means that std::map::key_type must be constructible from the the query key type.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download