diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 9eb45f502..6c7d32e49 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -38,6 +38,8 @@ struct hb_vector_t : std::conditional, hb_empty { typedef Type item_t; static constexpr unsigned item_size = hb_static_size (Type); + using array_t = typename std::conditional, hb_array_t>::type; + using c_array_t = typename std::conditional, hb_array_t>::type; hb_vector_t () = default; hb_vector_t (std::initializer_list lst) : hb_vector_t () @@ -147,24 +149,24 @@ struct hb_vector_t : std::conditional, hb_empty template hb_vector_t& operator << (T&& v) { push (std::forward (v)); return *this; } - hb_array_t< Type> as_array () { return hb_array (arrayZ, length); } - hb_array_t as_array () const { return hb_array (arrayZ, length); } + array_t as_array () { return hb_array (arrayZ, length); } + c_array_t as_array () const { return hb_array (arrayZ, length); } /* Iterator. */ - typedef hb_array_t iter_t; - typedef hb_array_t< Type> writer_t; + typedef c_array_t iter_t; + typedef array_t writer_t; iter_t iter () const { return as_array (); } writer_t writer () { return as_array (); } operator iter_t () const { return iter (); } operator writer_t () { return writer (); } - hb_array_t sub_array (unsigned int start_offset, unsigned int count) const + c_array_t sub_array (unsigned int start_offset, unsigned int count) const { return as_array ().sub_array (start_offset, count); } - hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const + c_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const { return as_array ().sub_array (start_offset, count); } - hb_array_t sub_array (unsigned int start_offset, unsigned int count) + array_t sub_array (unsigned int start_offset, unsigned int count) { return as_array ().sub_array (start_offset, count); } - hb_array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) + array_t sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) { return as_array ().sub_array (start_offset, count); } hb_sorted_array_t as_sorted_array () @@ -399,44 +401,6 @@ struct hb_vector_t : std::conditional, hb_empty }; template -struct hb_sorted_vector_t : hb_vector_t -{ - hb_sorted_vector_t () = default; - ~hb_sorted_vector_t () = default; - hb_sorted_vector_t (hb_sorted_vector_t& o) = default; - hb_sorted_vector_t (hb_sorted_vector_t &&o) = default; - hb_sorted_vector_t (std::initializer_list lst) : hb_vector_t (lst) {} - template - hb_sorted_vector_t (const Iterable &o) : hb_vector_t (o) {} - hb_sorted_vector_t& operator = (const hb_sorted_vector_t &o) = default; - hb_sorted_vector_t& operator = (hb_sorted_vector_t &&o) = default; - friend void swap (hb_sorted_vector_t& a, hb_sorted_vector_t& b) - { hb_swap ((hb_vector_t&) (a), (hb_vector_t&) (b)); } - - hb_sorted_array_t< Type> as_array () { return hb_sorted_array (this->arrayZ, this->length); } - hb_sorted_array_t as_array () const { return hb_sorted_array (this->arrayZ, this->length); } - - /* Iterator. */ - typedef hb_sorted_array_t const_iter_t; - typedef hb_sorted_array_t< Type> iter_t; - const_iter_t iter () const { return as_array (); } - const_iter_t citer () const { return as_array (); } - iter_t iter () { return as_array (); } - operator iter_t () { return iter (); } - operator const_iter_t () const { return iter (); } - - template - Type *bsearch (const T &x, Type *not_found = nullptr) - { return as_array ().bsearch (x, not_found); } - template - const Type *bsearch (const T &x, const Type *not_found = nullptr) const - { return as_array ().bsearch (x, not_found); } - template - bool bfind (const T &x, unsigned int *i = nullptr, - hb_not_found_t not_found = HB_NOT_FOUND_DONT_STORE, - unsigned int to_store = (unsigned int) -1) const - { return as_array ().bfind (x, i, not_found, to_store); } -}; +using hb_sorted_vector_t = hb_vector_t; #endif /* HB_VECTOR_HH */