[map] Allow geting non-const value pointer out with has()
This commit is contained in:
parent
00cfc5c17d
commit
61c0438425
|
@ -219,7 +219,8 @@ struct hb_hashmap_t
|
||||||
/* Has interface. */
|
/* Has interface. */
|
||||||
typedef const V& value_t;
|
typedef const V& value_t;
|
||||||
value_t operator [] (K k) const { return get (k); }
|
value_t operator [] (K k) const { return get (k); }
|
||||||
bool has (K key, const V **vp = nullptr) const
|
template <typename VV=V>
|
||||||
|
bool has (K key, VV **vp = nullptr) const
|
||||||
{
|
{
|
||||||
if (unlikely (!items))
|
if (unlikely (!items))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -217,6 +217,10 @@ main (int argc, char **argv)
|
||||||
hb_hashmap_t<int, hb::unique_ptr<hb_hashmap_t<int, int>>> m;
|
hb_hashmap_t<int, hb::unique_ptr<hb_hashmap_t<int, int>>> m;
|
||||||
|
|
||||||
m.get (0);
|
m.get (0);
|
||||||
|
const hb::unique_ptr<hb_hashmap_t<int, int>> *v1;
|
||||||
|
m.has (0, &v1);
|
||||||
|
hb::unique_ptr<hb_hashmap_t<int, int>> *v2;
|
||||||
|
m.has (0, &v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue