[set] Fix set copy/move constructors to actually work
Ouch!
This commit is contained in:
parent
76fc27713f
commit
a09dd87ca3
|
@ -158,15 +158,19 @@ struct hb_sparseset_t
|
|||
|
||||
struct hb_set_t : hb_sparseset_t<hb_bit_set_invertible_t>
|
||||
{
|
||||
hb_set_t () = default;
|
||||
using sparseset = hb_sparseset_t<hb_bit_set_invertible_t>;
|
||||
|
||||
~hb_set_t () = default;
|
||||
hb_set_t (hb_set_t&) = default;
|
||||
hb_set_t () : sparseset () {};
|
||||
hb_set_t (const hb_set_t &o) : sparseset ((sparseset &) o) {};
|
||||
hb_set_t (hb_set_t&& o) : sparseset (std::move ((sparseset &) o)) {}
|
||||
hb_set_t& operator= (const hb_set_t&) = default;
|
||||
hb_set_t& operator= (hb_set_t&&) = default;
|
||||
hb_set_t (std::initializer_list<hb_codepoint_t> lst) : hb_sparseset_t<hb_bit_set_invertible_t> (lst) {}
|
||||
hb_set_t (std::initializer_list<hb_codepoint_t> lst) : sparseset (lst) {}
|
||||
template <typename Iterable,
|
||||
hb_requires (hb_is_iterable (Iterable))>
|
||||
hb_set_t (const Iterable &o) : hb_sparseset_t<hb_bit_set_invertible_t> (o) {}
|
||||
hb_requires (hb_is_iterable (Iterable) &&
|
||||
!hb_is_same (hb_decay<Iterable>, hb_set_t))>
|
||||
hb_set_t (const Iterable &o) : sparseset (o) {}
|
||||
};
|
||||
|
||||
static_assert (hb_set_t::INVALID == HB_SET_VALUE_INVALID, "");
|
||||
|
|
|
@ -42,21 +42,24 @@ main (int argc, char **argv)
|
|||
/* Test copy assignment. */
|
||||
{
|
||||
hb_set_t v1 {1, 2};
|
||||
hb_set_t v2 = v1;
|
||||
hb_set_t v2;
|
||||
v2 = v1;
|
||||
assert (v1.get_population () == 2);
|
||||
assert (v2.get_population () == 2);
|
||||
}
|
||||
|
||||
/* Test move constructor. */
|
||||
{
|
||||
hb_set_t v {hb_set_t {1, 2}};
|
||||
hb_set_t v (hb_set_t {1, 2});
|
||||
assert (v.get_population () == 2);
|
||||
}
|
||||
|
||||
/* Test move assignment. */
|
||||
{
|
||||
hb_set_t s = hb_set_t {1, 2};
|
||||
hb_set_t v;
|
||||
v = hb_set_t {1, 2};
|
||||
v = std::move (s);
|
||||
assert (s.get_population () == 0);
|
||||
assert (v.get_population () == 2);
|
||||
}
|
||||
|
||||
|
@ -67,9 +70,15 @@ main (int argc, char **argv)
|
|||
s.add (18);
|
||||
s.add (12);
|
||||
|
||||
hb_set_t v (s);
|
||||
hb_vector_t<hb_codepoint_t> v (s);
|
||||
hb_set_t v0 (v);
|
||||
hb_set_t v1 (s);
|
||||
hb_set_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 initializing from iterator. */
|
||||
|
|
Loading…
Reference in New Issue