diff --git a/src/hb-algs.hh b/src/hb-algs.hh index b6ed7e958..34c376893 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -496,7 +496,7 @@ struct hb_pair_t hb_enable_if (std::is_default_constructible::value && std::is_default_constructible::value)> hb_pair_t () : first (), second () {} - hb_pair_t (T1 a, T2 b) : first (a), second (b) {} + hb_pair_t (T1 a, T2 b) : first (std::forward (a)), second (std::forward (b)) {} template & v) { set (v.first, v.second); return *this; } + hb_hashmap_t& operator << (const hb_pair_t& v) + { set (v.first, std::move (v.second)); return *this; } protected: diff --git a/src/test-map.cc b/src/test-map.cc index fa2752591..2127393f1 100644 --- a/src/test-map.cc +++ b/src/test-map.cc @@ -179,10 +179,18 @@ main (int argc, char **argv) hb_hashmap_t m1; - m1 << hb_pair_t {vector_t (), vector_t ()}; m1.set (vector_t (), vector_t {1}); m1.set (vector_t {1}, vector_t {2}); + m1 << hb_pair_t {vector_t {2}, vector_t ()}; + + vector_t v {3}; + assert (v.length == 1); + m1 << hb_pair_t {vector_t {3}, v}; + assert (v.length == 1); + m1 << hb_pair_t {vector_t {4}, std::move (v)}; + assert (v.length == 0); + assert (m1.get (vector_t ()) == vector_t {1}); assert (m1.get (vector_t {1}) == vector_t {2}); }