diff --git a/src/hb-map.hh b/src/hb-map.hh index 9341637ea..6f59fd8da 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -389,9 +389,10 @@ struct hb_map_t : hb_hashmap_t; - hb_map_t () = default; ~hb_map_t () = default; - hb_map_t (hb_map_t&) = default; + hb_map_t () : hashmap () {} + hb_map_t (const hb_map_t &o) : hashmap ((hashmap &) o) {} + hb_map_t (hb_map_t &&o) : hashmap (std::move ((hashmap &) o)) {} hb_map_t& operator= (const hb_map_t&) = default; hb_map_t& operator= (hb_map_t&&) = default; hb_map_t (std::initializer_list> lst) : hashmap (lst) {} diff --git a/src/hb-set.hh b/src/hb-set.hh index c9725e80c..9eacaf4f6 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -168,8 +168,7 @@ struct hb_set_t : hb_sparseset_t hb_set_t& operator= (hb_set_t&&) = default; hb_set_t (std::initializer_list lst) : sparseset (lst) {} template , hb_set_t))> + hb_requires (hb_is_iterable (Iterable))> hb_set_t (const Iterable &o) : sparseset (o) {} }; diff --git a/src/test-map.cc b/src/test-map.cc index fd2b2f0e6..ba31aed76 100644 --- a/src/test-map.cc +++ b/src/test-map.cc @@ -57,13 +57,21 @@ main (int argc, char **argv) /* Test move constructor. */ { - hb_map_t v {hb_map_t {}}; + hb_map_t s {}; + s.set (1, 2); + hb_map_t v (std::move (s)); + assert (s.get_population () == 0); + assert (v.get_population () == 1); } /* Test move assignment. */ { + hb_map_t s {}; + s.set (1, 2); hb_map_t v; - v = hb_map_t {}; + v = std::move (s); + assert (s.get_population () == 0); + assert (v.get_population () == 1); } /* Test initializing from iterable. */ @@ -73,9 +81,15 @@ main (int argc, char **argv) s.set (1, 2); s.set (3, 4); - hb_map_t v (s); + hb_vector_t> v (s); + hb_map_t v0 (v); + hb_map_t v1 (s); + hb_map_t v2 (std::move (s)); - assert (v.get_population () == 2); + assert (s.get_population () == 0); + assert (v0.get_population () == 2); + assert (v1.get_population () == 2); + assert (v2.get_population () == 2); } /* Test call fini() twice. */ diff --git a/src/test-set.cc b/src/test-set.cc index e28d7e65c..bcff05604 100644 --- a/src/test-set.cc +++ b/src/test-set.cc @@ -50,7 +50,9 @@ main (int argc, char **argv) /* Test move constructor. */ { - hb_set_t v (hb_set_t {1, 2}); + hb_set_t s {1, 2}; + hb_set_t v (std::move (s)); + assert (s.get_population () == 0); assert (v.get_population () == 2); }