[map] Add a couple more sink interfaces

This commit is contained in:
Behdad Esfahbod 2022-11-18 19:24:41 -07:00
parent 90226eab89
commit a3a218edb5
2 changed files with 6 additions and 0 deletions

View File

@ -320,6 +320,10 @@ struct hb_hashmap_t
{ set (v.first, v.second); return *this; }
hb_hashmap_t& operator << (const hb_pair_t<K, V&&>& v)
{ set (v.first, std::move (v.second)); return *this; }
hb_hashmap_t& operator << (const hb_pair_t<K&&, V>& v)
{ set (std::move (v.first), v.second); return *this; }
hb_hashmap_t& operator << (const hb_pair_t<K&&, V&&>& v)
{ set (std::move (v.first), std::move (v.second)); return *this; }
protected:

View File

@ -199,6 +199,8 @@ main (int argc, char **argv)
assert (v.length == 1);
m1 << hb_pair_t<vector_t, vector_t&&> {vector_t {4}, std::move (v)};
assert (v.length == 0);
m1 << hb_pair_t<vector_t&&, vector_t> {vector_t {4}, vector_t {5}};
m1 << hb_pair_t<vector_t&&, vector_t&&> {vector_t {4}, vector_t {5}};
hb_hashmap_t<vector_t, vector_t> m2;
vector_t v2 {3};