Opened 8 years ago

Closed 8 years ago

#799 closed enhancement (fixed)

allow conversion in get(map, key)

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.13
Component: utility Version:
Keywords: Cc:


The utility::get function is declared as

template <typename Key, typename Tp, typename Compare, typename Alloc>
const Tp& get(const std::map<Key, Tp, Compare, Alloc>& m, const Key& k);

which means, for example, if we have a map<string, int> we cannot call

get(map, "aha");

because map::key_type, string, is not same type as char[3]. It would be better to have an independent template type for second argument.

Change History (2)

comment:1 Changed 8 years ago by Peter

(In [3253]) refs #799. get_error: don't use operator<< on Key just to create an error message; it limits which types can be used heavily. Instead throw get_error that holds a copy of the key.

comment:2 Changed 8 years ago by Peter

Resolution: fixed
Status: newclosed

(In [3254]) fixes #799

Note: See TracTickets for help on using tickets.