Merge pull request #3278 from harfbuzz/more-std

More standard idioms
diff --git a/src/Makefile.am b/src/Makefile.am
index f405331..c0c7705 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -342,7 +342,20 @@
 test_gsub_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
 test_gsub_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
 
-COMPILED_TESTS = test-algs test-array test-iter test-meta test-number test-ot-tag test-priority-queue test-unicode-ranges test-bimap test-repacker
+COMPILED_TESTS = \
+	test-algs \
+	test-array \
+	test-iter \
+	test-map \
+	test-number \
+	test-ot-tag \
+	test-priority-queue \
+	test-set \
+	test-unicode-ranges \
+	test-vector \
+	test-bimap \
+	test-repacker \
+	$(NULL)
 COMPILED_TESTS_CPPFLAGS = $(HBCFLAGS) -DMAIN -UNDEBUG
 COMPILED_TESTS_LDADD = libharfbuzz.la $(HBLIBS)
 check_PROGRAMS += $(COMPILED_TESTS)
@@ -368,9 +381,9 @@
 test_iter_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
 test_iter_LDADD = $(COMPILED_TESTS_LDADD)
 
-test_meta_SOURCES = test-meta.cc hb-static.cc
-test_meta_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
-test_meta_LDADD = $(COMPILED_TESTS_LDADD)
+test_map_SOURCES = test-map.cc hb-static.cc
+test_map_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
+test_map_LDADD = $(COMPILED_TESTS_LDADD)
 
 test_number_SOURCES = test-number.cc hb-number.cc
 test_number_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
@@ -380,10 +393,18 @@
 test_ot_tag_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
 test_ot_tag_LDADD = $(COMPILED_TESTS_LDADD)
 
+test_set_SOURCES = test-set.cc hb-static.cc
+test_set_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
+test_set_LDADD = $(COMPILED_TESTS_LDADD)
+
 test_unicode_ranges_SOURCES = test-unicode-ranges.cc
 test_unicode_ranges_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
 test_unicode_ranges_LDADD = $(COMPILED_TESTS_LDADD)
 
+test_vector_SOURCES = test-vector.cc hb-static.cc
+test_vector_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
+test_vector_LDADD = $(COMPILED_TESTS_LDADD)
+
 test_bimap_SOURCES = test-bimap.cc hb-static.cc
 test_bimap_CPPFLAGS = $(COMPILED_TESTS_CPPFLAGS)
 test_bimap_LDADD = $(COMPILED_TESTS_LDADD)
diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index f20416c..1dcbe92 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -162,7 +162,7 @@
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
 		  first <= last &&
-		  valuesZ.sanitize (c, base, last - first + 1, hb_forward<Ts> (ds)...));
+		  valuesZ.sanitize (c, base, last - first + 1, std::forward<Ts> (ds)...));
   }
 
   HBGlyphID16	last;		/* Last GlyphID in this segment */
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index e4278f1..0354b47 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -775,11 +775,11 @@
     unsigned int subtable_type = get_type ();
     TRACE_DISPATCH (this, subtable_type);
     switch (subtable_type) {
-    case 0:	return_trace (c->dispatch (u.format0, hb_forward<Ts> (ds)...));
-    case 1:	return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2:	return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
-    case 4:	return_trace (c->dispatch (u.format4, hb_forward<Ts> (ds)...));
-    case 6:	return_trace (c->dispatch (u.format6, hb_forward<Ts> (ds)...));
+    case 0:	return_trace (c->dispatch (u.format0, std::forward<Ts> (ds)...));
+    case 1:	return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2:	return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
+    case 4:	return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
+    case 6:	return_trace (c->dispatch (u.format6, std::forward<Ts> (ds)...));
     default:	return_trace (c->default_return_value ());
     }
   }
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index 377ef87..b77c1f4 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -906,11 +906,11 @@
     unsigned int subtable_type = get_type ();
     TRACE_DISPATCH (this, subtable_type);
     switch (subtable_type) {
-    case Rearrangement:		return_trace (c->dispatch (u.rearrangement, hb_forward<Ts> (ds)...));
-    case Contextual:		return_trace (c->dispatch (u.contextual, hb_forward<Ts> (ds)...));
-    case Ligature:		return_trace (c->dispatch (u.ligature, hb_forward<Ts> (ds)...));
-    case Noncontextual:		return_trace (c->dispatch (u.noncontextual, hb_forward<Ts> (ds)...));
-    case Insertion:		return_trace (c->dispatch (u.insertion, hb_forward<Ts> (ds)...));
+    case Rearrangement:		return_trace (c->dispatch (u.rearrangement, std::forward<Ts> (ds)...));
+    case Contextual:		return_trace (c->dispatch (u.contextual, std::forward<Ts> (ds)...));
+    case Ligature:		return_trace (c->dispatch (u.ligature, std::forward<Ts> (ds)...));
+    case Noncontextual:		return_trace (c->dispatch (u.noncontextual, std::forward<Ts> (ds)...));
+    case Insertion:		return_trace (c->dispatch (u.insertion, std::forward<Ts> (ds)...));
     default:			return_trace (c->default_return_value ());
     }
   }
diff --git a/src/hb-algs.hh b/src/hb-algs.hh
index fc1aeb0..446d87e 100644
--- a/src/hb-algs.hh
+++ b/src/hb-algs.hh
@@ -35,6 +35,8 @@
 #include "hb-number.hh"
 
 #include <algorithm>
+#include <initializer_list>
+#include <new>
 
 /*
  * Flags
@@ -126,7 +128,7 @@
 template <typename Type>
 struct BEInt<Type, 3>
 {
-  static_assert (!hb_is_signed (Type), "");
+  static_assert (!std::is_signed<Type>::value, "");
   public:
   BEInt () = default;
   constexpr BEInt (Type V) : v {uint8_t ((V >> 16) & 0xFF),
@@ -180,7 +182,7 @@
 {
   /* Note.  This is dangerous in that if it's passed an rvalue, it returns rvalue-reference. */
   template <typename T> constexpr auto
-  operator () (T&& v) const HB_AUTO_RETURN ( hb_forward<T> (v) )
+  operator () (T&& v) const HB_AUTO_RETURN ( std::forward<T> (v) )
 }
 HB_FUNCOBJ (hb_identity);
 struct
@@ -204,7 +206,7 @@
 struct
 {
   template <typename T> constexpr bool
-  operator () (T&& v) const { return bool (hb_forward<T> (v)); }
+  operator () (T&& v) const { return bool (std::forward<T> (v)); }
 }
 HB_FUNCOBJ (hb_bool);
 
@@ -216,7 +218,7 @@
   impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, hb_deref (v).hash ())
 
   template <typename T,
-	    hb_enable_if (hb_is_integral (T))> constexpr auto
+	    hb_enable_if (std::is_integral<T>::value)> constexpr auto
   impl (const T& v, hb_priority<0>) const HB_AUTO_RETURN
   (
     /* Knuth's multiplicative method: */
@@ -238,26 +240,26 @@
   /* Pointer-to-member-function. */
   template <typename Appl, typename T, typename ...Ts> auto
   impl (Appl&& a, hb_priority<2>, T &&v, Ts&&... ds) const HB_AUTO_RETURN
-  ((hb_deref (hb_forward<T> (v)).*hb_forward<Appl> (a)) (hb_forward<Ts> (ds)...))
+  ((hb_deref (std::forward<T> (v)).*std::forward<Appl> (a)) (std::forward<Ts> (ds)...))
 
   /* Pointer-to-member. */
   template <typename Appl, typename T> auto
   impl (Appl&& a, hb_priority<1>, T &&v) const HB_AUTO_RETURN
-  ((hb_deref (hb_forward<T> (v))).*hb_forward<Appl> (a))
+  ((hb_deref (std::forward<T> (v))).*std::forward<Appl> (a))
 
   /* Operator(). */
   template <typename Appl, typename ...Ts> auto
   impl (Appl&& a, hb_priority<0>, Ts&&... ds) const HB_AUTO_RETURN
-  (hb_deref (hb_forward<Appl> (a)) (hb_forward<Ts> (ds)...))
+  (hb_deref (std::forward<Appl> (a)) (std::forward<Ts> (ds)...))
 
   public:
 
   template <typename Appl, typename ...Ts> auto
   operator () (Appl&& a, Ts&&... ds) const HB_AUTO_RETURN
   (
-    impl (hb_forward<Appl> (a),
+    impl (std::forward<Appl> (a),
 	  hb_prioritize,
-	  hb_forward<Ts> (ds)...)
+	  std::forward<Ts> (ds)...)
   )
 }
 HB_FUNCOBJ (hb_invoke);
@@ -276,9 +278,9 @@
 						   hb_declval (V),
 						   hb_declval (Ts)...))
   {
-    return hb_invoke (hb_forward<Appl> (a),
-		      hb_forward<V> (v),
-		      hb_forward<Ts> (ds)...);
+    return hb_invoke (std::forward<Appl> (a),
+		      std::forward<V> (v),
+		      std::forward<Ts> (ds)...);
   }
   template <typename T0, typename ...Ts,
 	    unsigned P = Pos,
@@ -288,10 +290,10 @@
 							    hb_declval (V),
 							    hb_declval (Ts)...))
   {
-    return hb_invoke (hb_forward<Appl> (a),
-		      hb_forward<T0> (d0),
-		      hb_forward<V> (v),
-		      hb_forward<Ts> (ds)...);
+    return hb_invoke (std::forward<Appl> (a),
+		      std::forward<T0> (d0),
+		      std::forward<V> (v),
+		      std::forward<Ts> (ds)...);
   }
 
   private:
@@ -325,14 +327,14 @@
 #define HB_PARTIALIZE(Pos) \
   template <typename _T> \
   decltype(auto) operator () (_T&& _v) const \
-  { return hb_partial<Pos> (this, hb_forward<_T> (_v)); } \
+  { return hb_partial<Pos> (this, std::forward<_T> (_v)); } \
   static_assert (true, "")
 #else
 /* https://github.com/harfbuzz/harfbuzz/issues/1724 */
 #define HB_PARTIALIZE(Pos) \
   template <typename _T> \
   auto operator () (_T&& _v) const HB_AUTO_RETURN \
-  (hb_partial<Pos> (+this, hb_forward<_T> (_v))) \
+  (hb_partial<Pos> (+this, std::forward<_T> (_v))) \
   static_assert (true, "")
 #endif
 
@@ -344,22 +346,22 @@
   template <typename Pred, typename Val> auto
   impl (Pred&& p, Val &&v, hb_priority<1>) const HB_AUTO_RETURN
   (
-    hb_deref (hb_forward<Pred> (p)).has (hb_forward<Val> (v))
+    hb_deref (std::forward<Pred> (p)).has (std::forward<Val> (v))
   )
 
   template <typename Pred, typename Val> auto
   impl (Pred&& p, Val &&v, hb_priority<0>) const HB_AUTO_RETURN
   (
-    hb_invoke (hb_forward<Pred> (p),
-	       hb_forward<Val> (v))
+    hb_invoke (std::forward<Pred> (p),
+	       std::forward<Val> (v))
   )
 
   public:
 
   template <typename Pred, typename Val> auto
   operator () (Pred&& p, Val &&v) const HB_RETURN (bool,
-    impl (hb_forward<Pred> (p),
-	  hb_forward<Val> (v),
+    impl (std::forward<Pred> (p),
+	  std::forward<Val> (v),
 	  hb_prioritize)
   )
 }
@@ -372,22 +374,22 @@
   template <typename Pred, typename Val> auto
   impl (Pred&& p, Val &&v, hb_priority<1>) const HB_AUTO_RETURN
   (
-    hb_has (hb_forward<Pred> (p),
-	    hb_forward<Val> (v))
+    hb_has (std::forward<Pred> (p),
+	    std::forward<Val> (v))
   )
 
   template <typename Pred, typename Val> auto
   impl (Pred&& p, Val &&v, hb_priority<0>) const HB_AUTO_RETURN
   (
-    hb_forward<Pred> (p) == hb_forward<Val> (v)
+    std::forward<Pred> (p) == std::forward<Val> (v)
   )
 
   public:
 
   template <typename Pred, typename Val> auto
   operator () (Pred&& p, Val &&v) const HB_RETURN (bool,
-    impl (hb_forward<Pred> (p),
-	  hb_forward<Val> (v),
+    impl (std::forward<Pred> (p),
+	  std::forward<Val> (v),
 	  hb_prioritize)
   )
 }
@@ -400,20 +402,20 @@
   template <typename Proj, typename Val> auto
   impl (Proj&& f, Val &&v, hb_priority<2>) const HB_AUTO_RETURN
   (
-    hb_deref (hb_forward<Proj> (f)).get (hb_forward<Val> (v))
+    hb_deref (std::forward<Proj> (f)).get (std::forward<Val> (v))
   )
 
   template <typename Proj, typename Val> auto
   impl (Proj&& f, Val &&v, hb_priority<1>) const HB_AUTO_RETURN
   (
-    hb_invoke (hb_forward<Proj> (f),
-	       hb_forward<Val> (v))
+    hb_invoke (std::forward<Proj> (f),
+	       std::forward<Val> (v))
   )
 
   template <typename Proj, typename Val> auto
   impl (Proj&& f, Val &&v, hb_priority<0>) const HB_AUTO_RETURN
   (
-    hb_forward<Proj> (f)[hb_forward<Val> (v)]
+    std::forward<Proj> (f)[std::forward<Val> (v)]
   )
 
   public:
@@ -421,8 +423,8 @@
   template <typename Proj, typename Val> auto
   operator () (Proj&& f, Val &&v) const HB_AUTO_RETURN
   (
-    impl (hb_forward<Proj> (f),
-	  hb_forward<Val> (v),
+    impl (std::forward<Proj> (f),
+	  std::forward<Val> (v),
 	  hb_prioritize)
   )
 }
@@ -435,19 +437,19 @@
   template <typename T1, typename T2> auto
   impl (T1&& v1, T2 &&v2, hb_priority<2>) const HB_AUTO_RETURN
   (
-    hb_forward<T2> (v2).cmp (hb_forward<T1> (v1)) == 0
+    std::forward<T2> (v2).cmp (std::forward<T1> (v1)) == 0
   )
 
   template <typename T1, typename T2> auto
   impl (T1&& v1, T2 &&v2, hb_priority<1>) const HB_AUTO_RETURN
   (
-    hb_forward<T1> (v1).cmp (hb_forward<T2> (v2)) == 0
+    std::forward<T1> (v1).cmp (std::forward<T2> (v2)) == 0
   )
 
   template <typename T1, typename T2> auto
   impl (T1&& v1, T2 &&v2, hb_priority<0>) const HB_AUTO_RETURN
   (
-    hb_forward<T1> (v1) == hb_forward<T2> (v2)
+    std::forward<T1> (v1) == std::forward<T2> (v2)
   )
 
   public:
@@ -455,8 +457,8 @@
   template <typename T1, typename T2> auto
   operator () (T1&& v1, T2 &&v2) const HB_AUTO_RETURN
   (
-    impl (hb_forward<T1> (v1),
-	  hb_forward<T2> (v2),
+    impl (std::forward<T1> (v1),
+	  std::forward<T2> (v2),
 	  hb_prioritize)
   )
 }
@@ -516,21 +518,21 @@
 {
   template <typename T, typename T2> constexpr auto
   operator () (T&& a, T2&& b) const HB_AUTO_RETURN
-  (a <= b ? hb_forward<T> (a) : hb_forward<T2> (b))
+  (a <= b ? std::forward<T> (a) : std::forward<T2> (b))
 }
 HB_FUNCOBJ (hb_min);
 struct
 {
   template <typename T, typename T2> constexpr auto
   operator () (T&& a, T2&& b) const HB_AUTO_RETURN
-  (a >= b ? hb_forward<T> (a) : hb_forward<T2> (b))
+  (a >= b ? std::forward<T> (a) : std::forward<T2> (b))
 }
 HB_FUNCOBJ (hb_max);
 struct
 {
   template <typename T, typename T2, typename T3> constexpr auto
   operator () (T&& x, T2&& min, T3&& max) const HB_AUTO_RETURN
-  (hb_min (hb_max (hb_forward<T> (x), hb_forward<T2> (min)), hb_forward<T3> (max)))
+  (hb_min (hb_max (std::forward<T> (x), std::forward<T2> (min)), std::forward<T3> (max)))
 }
 HB_FUNCOBJ (hb_clamp);
 
@@ -806,7 +808,7 @@
 template <typename T> static inline bool
 hb_in_range (T u, T lo, T hi)
 {
-  static_assert (!hb_is_signed<T>::value, "");
+  static_assert (!std::is_signed<T>::value, "");
 
   /* The casts below are important as if T is smaller than int,
    * the subtract results will become a signed int! */
diff --git a/src/hb-array.hh b/src/hb-array.hh
index ab0dd6e..8cae3c9 100644
--- a/src/hb-array.hh
+++ b/src/hb-array.hh
@@ -50,10 +50,11 @@
   /*
    * Constructors.
    */
-  hb_array_t () : arrayZ (nullptr), length (0), backwards_length (0) {}
-  hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_), backwards_length (0) {}
+  hb_array_t () = default;
+  ~hb_array_t () = default;
+  hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {}
   template <unsigned int length_>
-  hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_), backwards_length (0) {}
+  hb_array_t (Type (&array_)[length_]) : hb_array_t (array_, length_) {}
 
   template <typename U,
 	    hb_enable_if (hb_is_cr_convertible(U, Type))>
@@ -281,9 +282,9 @@
    */
 
   public:
-  Type *arrayZ;
-  unsigned int length;
-  unsigned int backwards_length;
+  Type *arrayZ = nullptr;
+  unsigned int length = 0;
+  unsigned int backwards_length = 0;
 };
 template <typename T> inline hb_array_t<T>
 hb_array (T *array, unsigned int length)
@@ -302,7 +303,7 @@
   static constexpr bool is_random_access_iterator = true;
   static constexpr bool is_sorted_iterator = true;
 
-  hb_sorted_array_t () : hb_array_t<Type> () {}
+  hb_sorted_array_t () = default;
   hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}
   template <unsigned int length_>
   hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {}
diff --git a/src/hb-bimap.hh b/src/hb-bimap.hh
index d409880..d466af8 100644
--- a/src/hb-bimap.hh
+++ b/src/hb-bimap.hh
@@ -33,15 +33,14 @@
 /* Bi-directional map */
 struct hb_bimap_t
 {
-  hb_bimap_t () { init (); }
-  ~hb_bimap_t () { fini (); }
-
+  /* XXX(remove) */
   void init ()
   {
     forw_map.init ();
     back_map.init ();
   }
 
+  /* XXX(remove) */
   void fini ()
   {
     forw_map.fini ();
@@ -99,14 +98,6 @@
 /* Inremental bimap: only lhs is given, rhs is incrementally assigned */
 struct hb_inc_bimap_t : hb_bimap_t
 {
-  hb_inc_bimap_t () { init (); }
-
-  void init ()
-  {
-    hb_bimap_t::init ();
-    next_value = 0;
-  }
-
   /* Add a mapping from lhs to rhs with a unique value if lhs is unknown.
    * Return the rhs value as the result.
    */
@@ -165,7 +156,7 @@
   }
 
   protected:
-  unsigned int	next_value;
+  unsigned int next_value = 0;
 };
 
 #endif /* HB_BIMAP_HH */
diff --git a/src/hb-bit-set-invertible.hh b/src/hb-bit-set-invertible.hh
index f48b72f..0832b0f 100644
--- a/src/hb-bit-set-invertible.hh
+++ b/src/hb-bit-set-invertible.hh
@@ -35,10 +35,20 @@
 struct hb_bit_set_invertible_t
 {
   hb_bit_set_t s;
-  bool inverted;
+  bool inverted = false;
 
-  hb_bit_set_invertible_t () { init (); }
-  ~hb_bit_set_invertible_t () { fini (); }
+  hb_bit_set_invertible_t () = default;
+  hb_bit_set_invertible_t (hb_bit_set_invertible_t& o) = default;
+  hb_bit_set_invertible_t (hb_bit_set_invertible_t&& o) = default;
+  hb_bit_set_invertible_t& operator= (const hb_bit_set_invertible_t& o) = default;
+  hb_bit_set_invertible_t& operator= (hb_bit_set_invertible_t&& o) = default;
+  friend void swap (hb_bit_set_invertible_t &a, hb_bit_set_invertible_t &b)
+  {
+    if (likely (!a.s.successful || !b.s.successful))
+      return;
+    hb_swap (a.inverted, b.inverted);
+    hb_swap (a.s, b.s);
+  }
 
   void init () { s.init (); inverted = false; }
   void fini () { s.fini (); }
diff --git a/src/hb-bit-set.hh b/src/hb-bit-set.hh
index c21778d..a471ee4 100644
--- a/src/hb-bit-set.hh
+++ b/src/hb-bit-set.hh
@@ -35,13 +35,22 @@
 
 struct hb_bit_set_t
 {
-  hb_bit_set_t () { init (); }
-  ~hb_bit_set_t () { fini (); }
+  hb_bit_set_t () = default;
+  ~hb_bit_set_t () = default;
 
   hb_bit_set_t (const hb_bit_set_t& other) : hb_bit_set_t () { set (other); }
-  void operator= (const hb_bit_set_t& other) { set (other); }
-  // TODO Add move construtor/assign
-  // TODO Add constructor for Iterator; with specialization for (sorted) vector / array?
+  hb_bit_set_t ( hb_bit_set_t&& other) : hb_bit_set_t () { hb_swap (*this, other); }
+  hb_bit_set_t& operator= (const hb_bit_set_t& other) { set (other); return *this; }
+  hb_bit_set_t& operator= (hb_bit_set_t&& other) { hb_swap (*this, other); return *this; }
+  friend void swap (hb_bit_set_t &a, hb_bit_set_t &b)
+  {
+    if (likely (!a.successful || !b.successful))
+      return;
+    hb_swap (a.population, b.population);
+    hb_swap (a.last_page_lookup, b.last_page_lookup);
+    hb_swap (a.page_map, b.page_map);
+    hb_swap (a.pages, b.pages);
+  }
 
   void init ()
   {
@@ -67,9 +76,9 @@
     uint32_t index;
   };
 
-  bool successful; /* Allocations successful */
-  mutable unsigned int population;
-  mutable unsigned int last_page_lookup;
+  bool successful = true; /* Allocations successful */
+  mutable unsigned int population = 0;
+  mutable unsigned int last_page_lookup = 0;
   hb_sorted_vector_t<page_map_t> page_map;
   hb_vector_t<page_t> pages;
 
diff --git a/src/hb-debug.hh b/src/hb-debug.hh
index f80c898..3ac7440 100644
--- a/src/hb-debug.hh
+++ b/src/hb-debug.hh
@@ -302,7 +302,7 @@
   {
     if (unlikely (returned)) {
       fprintf (stderr, "OUCH, double calls to return_trace().  This is a bug, please report.\n");
-      return hb_forward<T> (v);
+      return std::forward<T> (v);
     }
 
     _hb_debug_msg<max_level> (what, obj, func, true, plevel ? *plevel : 1, -1,
@@ -311,7 +311,7 @@
     if (plevel) --*plevel;
     plevel = nullptr;
     returned = true;
-    return hb_forward<T> (v);
+    return std::forward<T> (v);
   }
 
   private:
@@ -333,7 +333,7 @@
   template <typename T>
   T ret (T&& v,
 	 const char *func HB_UNUSED = nullptr,
-	 unsigned int line HB_UNUSED = 0) { return hb_forward<T> (v); }
+	 unsigned int line HB_UNUSED = 0) { return std::forward<T> (v); }
 };
 
 /* For disabled tracing; optimize out everything.
@@ -343,7 +343,7 @@
   template <typename T>
   T ret (T&& v,
 	 const char *func HB_UNUSED = nullptr,
-	 unsigned int line HB_UNUSED = 0) { return hb_forward<T> (v); }
+	 unsigned int line HB_UNUSED = 0) { return std::forward<T> (v); }
 };
 
 #define return_trace(RET) return trace.ret (RET, HB_FUNC, __LINE__)
diff --git a/src/hb-dispatch.hh b/src/hb-dispatch.hh
index 4b2b65a..37ca681 100644
--- a/src/hb-dispatch.hh
+++ b/src/hb-dispatch.hh
@@ -50,7 +50,7 @@
   bool may_dispatch (const T *obj HB_UNUSED, const F *format HB_UNUSED) { return true; }
   template <typename T, typename ...Ts>
   return_t dispatch (const T &obj, Ts&&... ds)
-  { return obj.dispatch (thiz (), hb_forward<Ts> (ds)...); }
+  { return obj.dispatch (thiz (), std::forward<Ts> (ds)...); }
   static return_t no_dispatch_return_value () { return Context::default_return_value (); }
   static bool stop_sublookup_iteration (const return_t r HB_UNUSED) { return false; }
   unsigned debug_depth = 0;
diff --git a/src/hb-iter.hh b/src/hb-iter.hh
index b8c4472..87b8ed8 100644
--- a/src/hb-iter.hh
+++ b/src/hb-iter.hh
@@ -162,7 +162,7 @@
 {
   template <typename T> hb_iter_type<T>
   operator () (T&& c) const
-  { return hb_deref (hb_forward<T> (c)).iter (); }
+  { return hb_deref (std::forward<T> (c)).iter (); }
 
   /* Specialization for C arrays. */
 
@@ -353,7 +353,7 @@
 template <typename Lhs, typename Rhs,
 	  hb_requires (hb_is_iterator (Lhs))>
 static inline auto
-operator | (Lhs&& lhs, Rhs&& rhs) HB_AUTO_RETURN (hb_forward<Rhs> (rhs) (hb_forward<Lhs> (lhs)))
+operator | (Lhs&& lhs, Rhs&& rhs) HB_AUTO_RETURN (std::forward<Rhs> (rhs) (std::forward<Lhs> (lhs)))
 
 /* hb_map(), hb_filter(), hb_reduce() */
 
@@ -674,8 +674,8 @@
   template <typename S2 = S>
   auto
   inc (hb_type_identity<S2> s, hb_priority<1>)
-    -> hb_void_t<decltype (hb_invoke (hb_forward<S2> (s), hb_declval<T&> ()))>
-  { v = hb_invoke (hb_forward<S2> (s), v); }
+    -> hb_void_t<decltype (hb_invoke (std::forward<S2> (s), hb_declval<T&> ()))>
+  { v = hb_invoke (std::forward<S2> (s), v); }
 
   void
   inc (S s, hb_priority<0>)
@@ -874,7 +874,7 @@
 		    Proj&& f = hb_identity) const
   {
     for (auto it = hb_iter (c); it; ++it)
-      if (!hb_match (hb_forward<Pred> (p), hb_get (hb_forward<Proj> (f), *it)))
+      if (!hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it)))
 	return false;
     return true;
   }
@@ -891,7 +891,7 @@
 		    Proj&& f = hb_identity) const
   {
     for (auto it = hb_iter (c); it; ++it)
-      if (hb_match (hb_forward<Pred> (p), hb_get (hb_forward<Proj> (f), *it)))
+      if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it)))
 	return true;
     return false;
   }
@@ -908,7 +908,7 @@
 		    Proj&& f = hb_identity) const
   {
     for (auto it = hb_iter (c); it; ++it)
-      if (hb_match (hb_forward<Pred> (p), hb_get (hb_forward<Proj> (f), *it)))
+      if (hb_match (std::forward<Pred> (p), hb_get (std::forward<Proj> (f), *it)))
 	return false;
     return true;
   }
diff --git a/src/hb-map.hh b/src/hb-map.hh
index dcd5267..790457f 100644
--- a/src/hb-map.hh
+++ b/src/hb-map.hh
@@ -35,16 +35,32 @@
  */
 
 template <typename K, typename V,
-	  K kINVALID = hb_is_pointer (K) ? 0 : hb_is_signed (K) ? hb_int_min (K) : (K) -1,
-	  V vINVALID = hb_is_pointer (V) ? 0 : hb_is_signed (V) ? hb_int_min (V) : (V) -1>
+	  K kINVALID = hb_is_pointer (K) ? 0 : std::is_signed<K>::value ? hb_int_min (K) : (K) -1,
+	  V vINVALID = hb_is_pointer (V) ? 0 : std::is_signed<V>::value ? hb_int_min (V) : (V) -1>
 struct hb_hashmap_t
 {
-  HB_DELETE_COPY_ASSIGN (hb_hashmap_t);
   hb_hashmap_t ()  { init (); }
   ~hb_hashmap_t () { fini (); }
 
-  static_assert (hb_is_integral (K) || hb_is_pointer (K), "");
-  static_assert (hb_is_integral (V) || hb_is_pointer (V), "");
+  hb_hashmap_t (const hb_hashmap_t& o) : hb_hashmap_t () { hb_copy (o, *this); }
+  hb_hashmap_t (hb_hashmap_t&& o) : hb_hashmap_t () { hb_swap (*this, o); }
+  hb_hashmap_t& operator= (const hb_hashmap_t&& o)  { hb_copy (o, *this); return *this; }
+  hb_hashmap_t& operator= (hb_hashmap_t&& o)  { hb_swap (*this, o); return *this; }
+
+  hb_hashmap_t (std::initializer_list<hb_pair_t<K, V>> lst) : hb_hashmap_t ()
+  {
+    for (auto&& item : lst)
+      set (item.first, item.second);
+  }
+  template <typename Iterable,
+	    hb_requires (hb_is_iterable (Iterable))>
+  hb_hashmap_t (const Iterable &o) : hb_hashmap_t ()
+  {
+    hb_copy (o, *this);
+  }
+
+  static_assert (std::is_integral<K>::value || hb_is_pointer (K), "");
+  static_assert (std::is_integral<V>::value || hb_is_pointer (V), "");
 
   struct item_t
   {
@@ -70,6 +86,16 @@
   unsigned int prime;
   item_t *items;
 
+  friend void swap (hb_hashmap_t& a, hb_hashmap_t& b)
+  {
+    if (unlikely (!a.successful || !b.successful))
+      return;
+    hb_swap (a.population, b.population);
+    hb_swap (a.occupancy, b.occupancy);
+    hb_swap (a.mask, b.mask);
+    hb_swap (a.prime, b.prime);
+    hb_swap (a.items, b.items);
+  }
   void init_shallow ()
   {
     successful = true;
@@ -133,17 +159,15 @@
 	if (old_items[i].is_real ())
 	  set_with_hash (old_items[i].key,
 			 old_items[i].hash,
-			 old_items[i].value);
+			 std::move (old_items[i].value));
 
     hb_free (old_items);
 
     return true;
   }
 
-  bool set (K key, V value)
-  {
-    return set_with_hash (key, hb_hash (key), value);
-  }
+  bool set (K key, const V& value) { return set_with_hash (key, hb_hash (key), value); }
+  bool set (K key, V&& value) { return set_with_hash (key, hb_hash (key), std::move (value)); }
 
   V get (K key) const
   {
@@ -213,7 +237,8 @@
 
   protected:
 
-  bool set_with_hash (K key, uint32_t hash, V value)
+  template <typename VV>
+  bool set_with_hash (K key, uint32_t hash, VV&& value)
   {
     if (unlikely (!successful)) return false;
     if (unlikely (key == kINVALID)) return true;
@@ -321,7 +346,22 @@
 struct hb_map_t : hb_hashmap_t<hb_codepoint_t,
 			       hb_codepoint_t,
 			       HB_MAP_VALUE_INVALID,
-			       HB_MAP_VALUE_INVALID> {};
+			       HB_MAP_VALUE_INVALID>
+{
+  using hashmap = hb_hashmap_t<hb_codepoint_t,
+			       hb_codepoint_t,
+			       HB_MAP_VALUE_INVALID,
+			       HB_MAP_VALUE_INVALID>;
 
+  hb_map_t () = default;
+  ~hb_map_t () = default;
+  hb_map_t (hb_map_t& o) = default;
+  hb_map_t& operator= (const hb_map_t& other) = default;
+  hb_map_t& operator= (hb_map_t&& other) = default;
+  hb_map_t (std::initializer_list<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> lst) : hashmap (lst) {}
+  template <typename Iterable,
+	    hb_requires (hb_is_iterable (Iterable))>
+  hb_map_t (const Iterable &o) : hashmap (o) {}
+};
 
 #endif /* HB_MAP_HH */
diff --git a/src/hb-meta.hh b/src/hb-meta.hh
index a714bc2..0ea5774 100644
--- a/src/hb-meta.hh
+++ b/src/hb-meta.hh
@@ -29,6 +29,9 @@
 
 #include "hb.hh"
 
+#include <type_traits>
+#include <utility>
+
 
 /*
  * C++ template meta-programming & fundamentals used with them.
@@ -129,40 +132,7 @@
 /* TODO Add feature-parity to std::decay. */
 template <typename T> using hb_decay = hb_remove_const<hb_remove_reference<T>>;
 
-
-template<bool B, class T, class F>
-struct _hb_conditional { typedef T type; };
-template<class T, class F>
-struct _hb_conditional<false, T, F> { typedef F type; };
-template<bool B, class T, class F>
-using hb_conditional = typename _hb_conditional<B, T, F>::type;
-
-
-template <typename From, typename To>
-struct hb_is_convertible
-{
-  private:
-  static constexpr bool   from_void = hb_is_same (void, hb_decay<From>);
-  static constexpr bool     to_void = hb_is_same (void, hb_decay<To>  );
-  static constexpr bool either_void = from_void || to_void;
-  static constexpr bool   both_void = from_void && to_void;
-
-  static hb_true_type impl2 (hb_conditional<to_void, int, To>);
-
-  template <typename T>
-  static auto impl (hb_priority<1>) -> decltype (impl2 (hb_declval (T)));
-  template <typename T>
-  static hb_false_type impl (hb_priority<0>);
-  public:
-  static constexpr bool value = both_void ||
-		       (!either_void &&
-			decltype (impl<hb_conditional<from_void, int, From>> (hb_prioritize))::value);
-};
-#define hb_is_convertible(From,To) hb_is_convertible<From, To>::value
-
-template <typename Base, typename Derived>
-using hb_is_base_of = hb_is_convertible<hb_decay<Derived> *, hb_decay<Base> *>;
-#define hb_is_base_of(Base,Derived) hb_is_base_of<Base, Derived>::value
+#define hb_is_convertible(From,To) std::is_convertible<From, To>::value
 
 template <typename From, typename To>
 using hb_is_cr_convertible = hb_bool_constant<
@@ -172,20 +142,11 @@
 >;
 #define hb_is_cr_convertible(From,To) hb_is_cr_convertible<From, To>::value
 
-/* std::move and std::forward */
-
-template <typename T>
-static constexpr hb_remove_reference<T>&& hb_move (T&& t) { return (hb_remove_reference<T>&&) (t); }
-
-template <typename T>
-static constexpr T&& hb_forward (hb_remove_reference<T>& t) { return (T&&) t; }
-template <typename T>
-static constexpr T&& hb_forward (hb_remove_reference<T>&& t) { return (T&&) t; }
 
 struct
 {
   template <typename T> constexpr auto
-  operator () (T&& v) const HB_AUTO_RETURN (hb_forward<T> (v))
+  operator () (T&& v) const HB_AUTO_RETURN (std::forward<T> (v))
 
   template <typename T> constexpr auto
   operator () (T *v) const HB_AUTO_RETURN (*v)
@@ -195,7 +156,7 @@
 struct
 {
   template <typename T> constexpr auto
-  operator () (T&& v) const HB_AUTO_RETURN (hb_forward<T> (v))
+  operator () (T&& v) const HB_AUTO_RETURN (std::forward<T> (v))
 
   template <typename T> constexpr auto
   operator () (T& v) const HB_AUTO_RETURN (hb_addressof (v))
@@ -226,50 +187,6 @@
 
 /* Type traits */
 
-template <typename T>
-using hb_is_integral = hb_bool_constant<
-  hb_is_same (hb_decay<T>, char) ||
-  hb_is_same (hb_decay<T>, signed char) ||
-  hb_is_same (hb_decay<T>, unsigned char) ||
-  hb_is_same (hb_decay<T>, signed int) ||
-  hb_is_same (hb_decay<T>, unsigned int) ||
-  hb_is_same (hb_decay<T>, signed short) ||
-  hb_is_same (hb_decay<T>, unsigned short) ||
-  hb_is_same (hb_decay<T>, signed long) ||
-  hb_is_same (hb_decay<T>, unsigned long) ||
-  hb_is_same (hb_decay<T>, signed long long) ||
-  hb_is_same (hb_decay<T>, unsigned long long) ||
-  false
->;
-#define hb_is_integral(T) hb_is_integral<T>::value
-template <typename T>
-using hb_is_floating_point = hb_bool_constant<
-  hb_is_same (hb_decay<T>, float) ||
-  hb_is_same (hb_decay<T>, double) ||
-  hb_is_same (hb_decay<T>, long double) ||
-  false
->;
-#define hb_is_floating_point(T) hb_is_floating_point<T>::value
-template <typename T>
-using hb_is_arithmetic = hb_bool_constant<
-  hb_is_integral (T) ||
-  hb_is_floating_point (T) ||
-  false
->;
-#define hb_is_arithmetic(T) hb_is_arithmetic<T>::value
-
-
-template <typename T, bool is_arithmetic> struct hb_is_signed_;
-template <typename T> struct hb_is_signed_<T, false>	: hb_false_type {};
-template <typename T> struct hb_is_signed_<T, true>	: hb_bool_constant<(T) -1 < (T) 0> {};
-template <typename T> struct hb_is_signed : hb_is_signed_<T, hb_is_arithmetic (T)> {};
-#define hb_is_signed(T) hb_is_signed<T>::value
-template <typename T, bool is_arithmetic> struct hb_is_unsigned_;
-template <typename T> struct hb_is_unsigned_<T, false>	: hb_false_type {};
-template <typename T> struct hb_is_unsigned_<T, true>	: hb_bool_constant<(T) 0 < (T) -1> {};
-template <typename T> struct hb_is_unsigned : hb_is_unsigned_<T, hb_is_arithmetic (T)> {};
-#define hb_is_unsigned(T) hb_is_unsigned<T>::value
-
 template <typename T> struct hb_int_min;
 template <> struct hb_int_min<char>			: hb_integral_constant<char,			CHAR_MIN>	{};
 template <> struct hb_int_min<signed char>		: hb_integral_constant<signed char,		SCHAR_MIN>	{};
@@ -309,108 +226,6 @@
   TypeName(const TypeName&) = delete; \
   void operator=(const TypeName&) = delete
 
-template <typename T, typename>
-struct _hb_is_destructible : hb_false_type {};
-template <typename T>
-struct _hb_is_destructible<T, hb_void_t<decltype (hb_declval (T).~T ())>> : hb_true_type {};
-template <typename T>
-using hb_is_destructible = _hb_is_destructible<T, void>;
-#define hb_is_destructible(T) hb_is_destructible<T>::value
-
-template <typename T, typename, typename ...Ts>
-struct _hb_is_constructible : hb_false_type {};
-template <typename T, typename ...Ts>
-struct _hb_is_constructible<T, hb_void_t<decltype (T (hb_declval (Ts)...))>, Ts...> : hb_true_type {};
-template <typename T, typename ...Ts>
-using hb_is_constructible = _hb_is_constructible<T, void, Ts...>;
-#define hb_is_constructible(...) hb_is_constructible<__VA_ARGS__>::value
-
-template <typename T>
-using hb_is_default_constructible = hb_is_constructible<T>;
-#define hb_is_default_constructible(T) hb_is_default_constructible<T>::value
-
-template <typename T>
-using hb_is_copy_constructible = hb_is_constructible<T, hb_add_lvalue_reference<hb_add_const<T>>>;
-#define hb_is_copy_constructible(T) hb_is_copy_constructible<T>::value
-
-template <typename T>
-using hb_is_move_constructible = hb_is_constructible<T, hb_add_rvalue_reference<hb_add_const<T>>>;
-#define hb_is_move_constructible(T) hb_is_move_constructible<T>::value
-
-template <typename T, typename U, typename>
-struct _hb_is_assignable : hb_false_type {};
-template <typename T, typename U>
-struct _hb_is_assignable<T, U, hb_void_t<decltype (hb_declval (T) = hb_declval (U))>> : hb_true_type {};
-template <typename T, typename U>
-using hb_is_assignable = _hb_is_assignable<T, U, void>;
-#define hb_is_assignable(T,U) hb_is_assignable<T, U>::value
-
-template <typename T>
-using hb_is_copy_assignable = hb_is_assignable<hb_add_lvalue_reference<T>,
-					       hb_add_lvalue_reference<hb_add_const<T>>>;
-#define hb_is_copy_assignable(T) hb_is_copy_assignable<T>::value
-
-template <typename T>
-using hb_is_move_assignable = hb_is_assignable<hb_add_lvalue_reference<T>,
-					       hb_add_rvalue_reference<T>>;
-#define hb_is_move_assignable(T) hb_is_move_assignable<T>::value
-
-/* Trivial versions. */
-
-template <typename T> union hb_trivial { T value; };
-
-template <typename T>
-using hb_is_trivially_destructible= hb_is_destructible<hb_trivial<T>>;
-#define hb_is_trivially_destructible(T) hb_is_trivially_destructible<T>::value
-
-/* Don't know how to do the following. */
-//template <typename T, typename ...Ts>
-//using hb_is_trivially_constructible= hb_is_constructible<hb_trivial<T>, hb_trivial<Ts>...>;
-//#define hb_is_trivially_constructible(...) hb_is_trivially_constructible<__VA_ARGS__>::value
-
-template <typename T>
-using hb_is_trivially_default_constructible= hb_is_default_constructible<hb_trivial<T>>;
-#define hb_is_trivially_default_constructible(T) hb_is_trivially_default_constructible<T>::value
-
-template <typename T>
-using hb_is_trivially_copy_constructible= hb_is_copy_constructible<hb_trivial<T>>;
-#define hb_is_trivially_copy_constructible(T) hb_is_trivially_copy_constructible<T>::value
-
-template <typename T>
-using hb_is_trivially_move_constructible= hb_is_move_constructible<hb_trivial<T>>;
-#define hb_is_trivially_move_constructible(T) hb_is_trivially_move_constructible<T>::value
-
-/* Don't know how to do the following. */
-//template <typename T, typename U>
-//using hb_is_trivially_assignable= hb_is_assignable<hb_trivial<T>, hb_trivial<U>>;
-//#define hb_is_trivially_assignable(T,U) hb_is_trivially_assignable<T, U>::value
-
-template <typename T>
-using hb_is_trivially_copy_assignable= hb_is_copy_assignable<hb_trivial<T>>;
-#define hb_is_trivially_copy_assignable(T) hb_is_trivially_copy_assignable<T>::value
-
-template <typename T>
-using hb_is_trivially_move_assignable= hb_is_move_assignable<hb_trivial<T>>;
-#define hb_is_trivially_move_assignable(T) hb_is_trivially_move_assignable<T>::value
-
-template <typename T>
-using hb_is_trivially_copyable= hb_bool_constant<
-  hb_is_trivially_destructible (T) &&
-  (!hb_is_move_assignable (T) || hb_is_trivially_move_assignable (T)) &&
-  (!hb_is_move_constructible (T) || hb_is_trivially_move_constructible (T)) &&
-  (!hb_is_copy_assignable (T) || hb_is_trivially_copy_assignable (T)) &&
-  (!hb_is_copy_constructible (T) || hb_is_trivially_copy_constructible (T)) &&
-  true
->;
-#define hb_is_trivially_copyable(T) hb_is_trivially_copyable<T>::value
-
-template <typename T>
-using hb_is_trivial= hb_bool_constant<
-  hb_is_trivially_copyable (T) &&
-  hb_is_trivially_default_constructible (T)
->;
-#define hb_is_trivial(T) hb_is_trivial<T>::value
-
 /* hb_unwrap_type (T)
  * If T has no T::type, returns T. Otherwise calls itself on T::type recursively.
  */
diff --git a/src/hb-mutex.hh b/src/hb-mutex.hh
index 29c3f8b..4e13502 100644
--- a/src/hb-mutex.hh
+++ b/src/hb-mutex.hh
@@ -73,7 +73,6 @@
 #elif !defined(HB_NO_MT)
 
 #include <mutex>
-#include <new>
 typedef std::mutex              hb_mutex_impl_t;
 #define hb_mutex_impl_init(M)   HB_STMT_START { new (M) hb_mutex_impl_t; } HB_STMT_END
 #define hb_mutex_impl_lock(M)   (M)->lock ()
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 5199d1c..7e52417 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -64,7 +64,7 @@
   IntType& operator = (Type i) { v = i; return *this; }
   /* For reason we define cast out operator for signed/unsigned, instead of Type, see:
    * https://github.com/harfbuzz/harfbuzz/pull/2875/commits/09836013995cab2b9f07577a179ad7b024130467 */
-  operator hb_conditional<hb_is_signed (Type), signed, unsigned> () const { return v; }
+  operator typename std::conditional<std::is_signed<Type>::value, signed, unsigned>::type () const { return v; }
 
   bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; }
   bool operator != (const IntType &o) const { return !(*this == o); }
@@ -86,7 +86,7 @@
     return pb->cmp (*pa);
   }
   template <typename Type2,
-	    hb_enable_if (hb_is_integral (Type2) &&
+	    hb_enable_if (std::is_integral<Type2>::value &&
 			  sizeof (Type2) < sizeof (int) &&
 			  sizeof (Type) < sizeof (int))>
   int cmp (Type2 a) const
@@ -341,7 +341,7 @@
 
     s->push ();
 
-    bool ret = c->dispatch (src_base+src, hb_forward<Ts> (ds)...);
+    bool ret = c->dispatch (src_base+src, std::forward<Ts> (ds)...);
 
     if (ret || !has_null)
       s->add_link (*this, s->pop_pack ());
@@ -358,7 +358,7 @@
     *this = 0;
 
     Type* obj = c->push<Type> ();
-    bool ret = obj->serialize (c, hb_forward<Ts> (ds)...);
+    bool ret = obj->serialize (c, std::forward<Ts> (ds)...);
 
     if (ret)
       c->add_link (*this, c->pop_pack ());
@@ -384,7 +384,7 @@
 
     c->push ();
 
-    bool ret = c->copy (src_base+src, hb_forward<Ts> (ds)...);
+    bool ret = c->copy (src_base+src, std::forward<Ts> (ds)...);
 
     c->add_link (*this, c->pop_pack (), whence, dst_bias);
 
@@ -410,7 +410,7 @@
     TRACE_SANITIZE (this);
     return_trace (sanitize_shallow (c, base) &&
 		  (this->is_null () ||
-		   c->dispatch (StructAtOffset<Type> (base, *this), hb_forward<Ts> (ds)...) ||
+		   c->dispatch (StructAtOffset<Type> (base, *this), std::forward<Ts> (ds)...) ||
 		   neuter (c)));
   }
 
@@ -518,9 +518,9 @@
   {
     TRACE_SANITIZE (this);
     if (unlikely (!sanitize_shallow (c, count))) return_trace (false);
-    if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true);
+    if (!sizeof... (Ts) && std::is_trivially_copyable<Type>::value) return_trace (true);
     for (unsigned int i = 0; i < count; i++)
-      if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
+      if (unlikely (!c->dispatch (arrayZ[i], std::forward<Ts> (ds)...)))
 	return_trace (false);
     return_trace (true);
   }
@@ -565,7 +565,7 @@
   {
     TRACE_SANITIZE (this);
     return_trace ((UnsizedArray16OfOffsetTo<Type, OffsetType, has_null>
-		   ::sanitize (c, count, this, hb_forward<Ts> (ds)...)));
+		   ::sanitize (c, count, this, std::forward<Ts> (ds)...)));
   }
 };
 
@@ -707,10 +707,10 @@
   {
     TRACE_SANITIZE (this);
     if (unlikely (!sanitize_shallow (c))) return_trace (false);
-    if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true);
+    if (!sizeof... (Ts) && std::is_trivially_copyable<Type>::value) return_trace (true);
     unsigned int count = len;
     for (unsigned int i = 0; i < count; i++)
-      if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
+      if (unlikely (!c->dispatch (arrayZ[i], std::forward<Ts> (ds)...)))
 	return_trace (false);
     return_trace (true);
   }
@@ -768,7 +768,7 @@
   bool sanitize (hb_sanitize_context_t *c, Ts&&... ds) const
   {
     TRACE_SANITIZE (this);
-    return_trace (Array16OfOffset16To<Type>::sanitize (c, this, hb_forward<Ts> (ds)...));
+    return_trace (Array16OfOffset16To<Type>::sanitize (c, this, std::forward<Ts> (ds)...));
   }
 };
 
@@ -835,10 +835,10 @@
   {
     TRACE_SANITIZE (this);
     if (unlikely (!sanitize_shallow (c))) return_trace (false);
-    if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true);
+    if (!sizeof... (Ts) && std::is_trivially_copyable<Type>::value) return_trace (true);
     unsigned int count = get_length ();
     for (unsigned int i = 0; i < count; i++)
-      if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
+      if (unlikely (!c->dispatch (arrayZ[i], std::forward<Ts> (ds)...)))
 	return_trace (false);
     return_trace (true);
   }
@@ -884,10 +884,10 @@
   {
     TRACE_SANITIZE (this);
     if (unlikely (!sanitize_shallow (c))) return_trace (false);
-    if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true);
+    if (!sizeof... (Ts) && std::is_trivially_copyable<Type>::value) return_trace (true);
     unsigned int count = lenM1 + 1;
     for (unsigned int i = 0; i < count; i++)
-      if (unlikely (!c->dispatch (arrayZ[i], hb_forward<Ts> (ds)...)))
+      if (unlikely (!c->dispatch (arrayZ[i], std::forward<Ts> (ds)...)))
 	return_trace (false);
     return_trace (true);
   }
@@ -1070,10 +1070,10 @@
   {
     TRACE_SANITIZE (this);
     if (unlikely (!sanitize_shallow (c))) return_trace (false);
-    if (!sizeof... (Ts) && hb_is_trivially_copyable (Type)) return_trace (true);
+    if (!sizeof... (Ts) && std::is_trivially_copyable<Type>::value) return_trace (true);
     unsigned int count = get_length ();
     for (unsigned int i = 0; i < count; i++)
-      if (unlikely (!(*this)[i].sanitize (c, hb_forward<Ts> (ds)...)))
+      if (unlikely (!(*this)[i].sanitize (c, std::forward<Ts> (ds)...)))
 	return_trace (false);
     return_trace (true);
   }
diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh
index eaaf5e1..180c87c 100644
--- a/src/hb-ot-cff-common.hh
+++ b/src/hb-ot-cff-common.hh
@@ -373,7 +373,7 @@
   {
     TRACE_SERIALIZE (this);
     for (unsigned int i = 0; i < dictval.get_count (); i++)
-      if (unlikely (!opszr.serialize (c, dictval[i], hb_forward<Ts> (ds)...)))
+      if (unlikely (!opszr.serialize (c, dictval[i], std::forward<Ts> (ds)...)))
 	return_trace (false);
 
     return_trace (true);
diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh
index 9f34e56..936ea0b 100644
--- a/src/hb-ot-color-colr-table.hh
+++ b/src/hb-ot-color-colr-table.hh
@@ -925,8 +925,8 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -1065,38 +1065,38 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.paintformat1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.paintformat2, hb_forward<Ts> (ds)...));
-    case 3: return_trace (c->dispatch (u.paintformat3, hb_forward<Ts> (ds)...));
-    case 4: return_trace (c->dispatch (u.paintformat4, hb_forward<Ts> (ds)...));
-    case 5: return_trace (c->dispatch (u.paintformat5, hb_forward<Ts> (ds)...));
-    case 6: return_trace (c->dispatch (u.paintformat6, hb_forward<Ts> (ds)...));
-    case 7: return_trace (c->dispatch (u.paintformat7, hb_forward<Ts> (ds)...));
-    case 8: return_trace (c->dispatch (u.paintformat8, hb_forward<Ts> (ds)...));
-    case 9: return_trace (c->dispatch (u.paintformat9, hb_forward<Ts> (ds)...));
-    case 10: return_trace (c->dispatch (u.paintformat10, hb_forward<Ts> (ds)...));
-    case 11: return_trace (c->dispatch (u.paintformat11, hb_forward<Ts> (ds)...));
-    case 12: return_trace (c->dispatch (u.paintformat12, hb_forward<Ts> (ds)...));
-    case 13: return_trace (c->dispatch (u.paintformat13, hb_forward<Ts> (ds)...));
-    case 14: return_trace (c->dispatch (u.paintformat14, hb_forward<Ts> (ds)...));
-    case 15: return_trace (c->dispatch (u.paintformat15, hb_forward<Ts> (ds)...));
-    case 16: return_trace (c->dispatch (u.paintformat16, hb_forward<Ts> (ds)...));
-    case 17: return_trace (c->dispatch (u.paintformat17, hb_forward<Ts> (ds)...));
-    case 18: return_trace (c->dispatch (u.paintformat18, hb_forward<Ts> (ds)...));
-    case 19: return_trace (c->dispatch (u.paintformat19, hb_forward<Ts> (ds)...));
-    case 20: return_trace (c->dispatch (u.paintformat20, hb_forward<Ts> (ds)...));
-    case 21: return_trace (c->dispatch (u.paintformat21, hb_forward<Ts> (ds)...));
-    case 22: return_trace (c->dispatch (u.paintformat22, hb_forward<Ts> (ds)...));
-    case 23: return_trace (c->dispatch (u.paintformat23, hb_forward<Ts> (ds)...));
-    case 24: return_trace (c->dispatch (u.paintformat24, hb_forward<Ts> (ds)...));
-    case 25: return_trace (c->dispatch (u.paintformat25, hb_forward<Ts> (ds)...));
-    case 26: return_trace (c->dispatch (u.paintformat26, hb_forward<Ts> (ds)...));
-    case 27: return_trace (c->dispatch (u.paintformat27, hb_forward<Ts> (ds)...));
-    case 28: return_trace (c->dispatch (u.paintformat28, hb_forward<Ts> (ds)...));
-    case 29: return_trace (c->dispatch (u.paintformat29, hb_forward<Ts> (ds)...));
-    case 30: return_trace (c->dispatch (u.paintformat30, hb_forward<Ts> (ds)...));
-    case 31: return_trace (c->dispatch (u.paintformat31, hb_forward<Ts> (ds)...));
-    case 32: return_trace (c->dispatch (u.paintformat32, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.paintformat1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.paintformat2, std::forward<Ts> (ds)...));
+    case 3: return_trace (c->dispatch (u.paintformat3, std::forward<Ts> (ds)...));
+    case 4: return_trace (c->dispatch (u.paintformat4, std::forward<Ts> (ds)...));
+    case 5: return_trace (c->dispatch (u.paintformat5, std::forward<Ts> (ds)...));
+    case 6: return_trace (c->dispatch (u.paintformat6, std::forward<Ts> (ds)...));
+    case 7: return_trace (c->dispatch (u.paintformat7, std::forward<Ts> (ds)...));
+    case 8: return_trace (c->dispatch (u.paintformat8, std::forward<Ts> (ds)...));
+    case 9: return_trace (c->dispatch (u.paintformat9, std::forward<Ts> (ds)...));
+    case 10: return_trace (c->dispatch (u.paintformat10, std::forward<Ts> (ds)...));
+    case 11: return_trace (c->dispatch (u.paintformat11, std::forward<Ts> (ds)...));
+    case 12: return_trace (c->dispatch (u.paintformat12, std::forward<Ts> (ds)...));
+    case 13: return_trace (c->dispatch (u.paintformat13, std::forward<Ts> (ds)...));
+    case 14: return_trace (c->dispatch (u.paintformat14, std::forward<Ts> (ds)...));
+    case 15: return_trace (c->dispatch (u.paintformat15, std::forward<Ts> (ds)...));
+    case 16: return_trace (c->dispatch (u.paintformat16, std::forward<Ts> (ds)...));
+    case 17: return_trace (c->dispatch (u.paintformat17, std::forward<Ts> (ds)...));
+    case 18: return_trace (c->dispatch (u.paintformat18, std::forward<Ts> (ds)...));
+    case 19: return_trace (c->dispatch (u.paintformat19, std::forward<Ts> (ds)...));
+    case 20: return_trace (c->dispatch (u.paintformat20, std::forward<Ts> (ds)...));
+    case 21: return_trace (c->dispatch (u.paintformat21, std::forward<Ts> (ds)...));
+    case 22: return_trace (c->dispatch (u.paintformat22, std::forward<Ts> (ds)...));
+    case 23: return_trace (c->dispatch (u.paintformat23, std::forward<Ts> (ds)...));
+    case 24: return_trace (c->dispatch (u.paintformat24, std::forward<Ts> (ds)...));
+    case 25: return_trace (c->dispatch (u.paintformat25, std::forward<Ts> (ds)...));
+    case 26: return_trace (c->dispatch (u.paintformat26, std::forward<Ts> (ds)...));
+    case 27: return_trace (c->dispatch (u.paintformat27, std::forward<Ts> (ds)...));
+    case 28: return_trace (c->dispatch (u.paintformat28, std::forward<Ts> (ds)...));
+    case 29: return_trace (c->dispatch (u.paintformat29, std::forward<Ts> (ds)...));
+    case 30: return_trace (c->dispatch (u.paintformat30, std::forward<Ts> (ds)...));
+    case 31: return_trace (c->dispatch (u.paintformat31, std::forward<Ts> (ds)...));
+    case 32: return_trace (c->dispatch (u.paintformat32, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 3563cab..ffa11bc 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -134,11 +134,11 @@
     switch (subtable_type) {
     case 0:	return_trace (c->dispatch (u.format0));
 #ifndef HB_NO_AAT_SHAPE
-    case 1:	return_trace (u.header.apple ? c->dispatch (u.format1, hb_forward<Ts> (ds)...) : c->default_return_value ());
+    case 1:	return_trace (u.header.apple ? c->dispatch (u.format1, std::forward<Ts> (ds)...) : c->default_return_value ());
 #endif
     case 2:	return_trace (c->dispatch (u.format2));
 #ifndef HB_NO_AAT_SHAPE
-    case 3:	return_trace (u.header.apple ? c->dispatch (u.format3, hb_forward<Ts> (ds)...) : c->default_return_value ());
+    case 3:	return_trace (u.header.apple ? c->dispatch (u.format3, std::forward<Ts> (ds)...) : c->default_return_value ());
 #endif
     default:	return_trace (c->default_return_value ());
     }
@@ -325,9 +325,9 @@
     unsigned int subtable_type = get_type ();
     TRACE_DISPATCH (this, subtable_type);
     switch (subtable_type) {
-    case 0:	return_trace (c->dispatch (u.ot, hb_forward<Ts> (ds)...));
+    case 0:	return_trace (c->dispatch (u.ot, std::forward<Ts> (ds)...));
 #ifndef HB_NO_AAT_SHAPE
-    case 1:	return_trace (c->dispatch (u.aat, hb_forward<Ts> (ds)...));
+    case 1:	return_trace (c->dispatch (u.aat, std::forward<Ts> (ds)...));
 #endif
     default:	return_trace (c->default_return_value ());
     }
diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index 87ac878..a43f5f8 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -1286,7 +1286,7 @@
     TRACE_DISPATCH (this, lookup_type);
     unsigned int count = get_subtable_count ();
     for (unsigned int i = 0; i < count; i++) {
-      typename context_t::return_t r = get_subtable<TSubTable> (i).dispatch (c, lookup_type, hb_forward<Ts> (ds)...);
+      typename context_t::return_t r = get_subtable<TSubTable> (i).dispatch (c, lookup_type, std::forward<Ts> (ds)...);
       if (c->stop_sublookup_iteration (r))
 	return_trace (r);
     }
@@ -2984,7 +2984,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index 31a4a3e..41c5a1e 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -248,9 +248,9 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
-    case 3: return_trace (c->dispatch (u.format3, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
+    case 3: return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index ac8f6ea..a8fb5c7 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1050,8 +1050,8 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -1702,8 +1702,8 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -1959,7 +1959,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -2194,7 +2194,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -2434,7 +2434,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -2653,7 +2653,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -2704,15 +2704,15 @@
   {
     TRACE_DISPATCH (this, lookup_type);
     switch (lookup_type) {
-    case Single:		return_trace (u.single.dispatch (c, hb_forward<Ts> (ds)...));
-    case Pair:			return_trace (u.pair.dispatch (c, hb_forward<Ts> (ds)...));
-    case Cursive:		return_trace (u.cursive.dispatch (c, hb_forward<Ts> (ds)...));
-    case MarkBase:		return_trace (u.markBase.dispatch (c, hb_forward<Ts> (ds)...));
-    case MarkLig:		return_trace (u.markLig.dispatch (c, hb_forward<Ts> (ds)...));
-    case MarkMark:		return_trace (u.markMark.dispatch (c, hb_forward<Ts> (ds)...));
-    case Context:		return_trace (u.context.dispatch (c, hb_forward<Ts> (ds)...));
-    case ChainContext:		return_trace (u.chainContext.dispatch (c, hb_forward<Ts> (ds)...));
-    case Extension:		return_trace (u.extension.dispatch (c, hb_forward<Ts> (ds)...));
+    case Single:		return_trace (u.single.dispatch (c, std::forward<Ts> (ds)...));
+    case Pair:			return_trace (u.pair.dispatch (c, std::forward<Ts> (ds)...));
+    case Cursive:		return_trace (u.cursive.dispatch (c, std::forward<Ts> (ds)...));
+    case MarkBase:		return_trace (u.markBase.dispatch (c, std::forward<Ts> (ds)...));
+    case MarkLig:		return_trace (u.markLig.dispatch (c, std::forward<Ts> (ds)...));
+    case MarkMark:		return_trace (u.markMark.dispatch (c, std::forward<Ts> (ds)...));
+    case Context:		return_trace (u.context.dispatch (c, std::forward<Ts> (ds)...));
+    case ChainContext:		return_trace (u.chainContext.dispatch (c, std::forward<Ts> (ds)...));
+    case Extension:		return_trace (u.extension.dispatch (c, std::forward<Ts> (ds)...));
     default:			return_trace (c->default_return_value ());
     }
   }
@@ -2800,7 +2800,7 @@
 
   template <typename context_t, typename ...Ts>
   typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
-  { return Lookup::dispatch<SubTable> (c, hb_forward<Ts> (ds)...); }
+  { return Lookup::dispatch<SubTable> (c, std::forward<Ts> (ds)...); }
 
   bool subset (hb_subset_context_t *c) const
   { return Lookup::subset<SubTable> (c); }
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 55edfd4..0dcc98c 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -290,8 +290,8 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -524,7 +524,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -767,7 +767,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -1152,7 +1152,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -1395,7 +1395,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -1434,14 +1434,14 @@
   {
     TRACE_DISPATCH (this, lookup_type);
     switch (lookup_type) {
-    case Single:		return_trace (u.single.dispatch (c, hb_forward<Ts> (ds)...));
-    case Multiple:		return_trace (u.multiple.dispatch (c, hb_forward<Ts> (ds)...));
-    case Alternate:		return_trace (u.alternate.dispatch (c, hb_forward<Ts> (ds)...));
-    case Ligature:		return_trace (u.ligature.dispatch (c, hb_forward<Ts> (ds)...));
-    case Context:		return_trace (u.context.dispatch (c, hb_forward<Ts> (ds)...));
-    case ChainContext:		return_trace (u.chainContext.dispatch (c, hb_forward<Ts> (ds)...));
-    case Extension:		return_trace (u.extension.dispatch (c, hb_forward<Ts> (ds)...));
-    case ReverseChainSingle:	return_trace (u.reverseChainContextSingle.dispatch (c, hb_forward<Ts> (ds)...));
+    case Single:		return_trace (u.single.dispatch (c, std::forward<Ts> (ds)...));
+    case Multiple:		return_trace (u.multiple.dispatch (c, std::forward<Ts> (ds)...));
+    case Alternate:		return_trace (u.alternate.dispatch (c, std::forward<Ts> (ds)...));
+    case Ligature:		return_trace (u.ligature.dispatch (c, std::forward<Ts> (ds)...));
+    case Context:		return_trace (u.context.dispatch (c, std::forward<Ts> (ds)...));
+    case ChainContext:		return_trace (u.chainContext.dispatch (c, std::forward<Ts> (ds)...));
+    case Extension:		return_trace (u.extension.dispatch (c, std::forward<Ts> (ds)...));
+    case ReverseChainSingle:	return_trace (u.reverseChainContextSingle.dispatch (c, std::forward<Ts> (ds)...));
     default:			return_trace (c->default_return_value ());
     }
   }
@@ -1667,7 +1667,7 @@
 
   template <typename context_t, typename ...Ts>
   typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
-  { return Lookup::dispatch<SubTable> (c, hb_forward<Ts> (ds)...); }
+  { return Lookup::dispatch<SubTable> (c, std::forward<Ts> (ds)...); }
 
   bool subset (hb_subset_context_t *c) const
   { return Lookup::subset<SubTable> (c); }
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 9b958a8..fde273e 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2288,9 +2288,9 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
-    case 3: return_trace (c->dispatch (u.format3, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
+    case 3: return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -3358,9 +3358,9 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
-    case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
-    case 3: return_trace (c->dispatch (u.format3, hb_forward<Ts> (ds)...));
+    case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
+    case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
+    case 3: return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
@@ -3389,7 +3389,7 @@
   {
     TRACE_DISPATCH (this, format);
     if (unlikely (!c->may_dispatch (this, this))) return_trace (c->no_dispatch_return_value ());
-    return_trace (get_subtable<typename T::SubTable> ().dispatch (c, get_type (), hb_forward<Ts> (ds)...));
+    return_trace (get_subtable<typename T::SubTable> ().dispatch (c, get_type (), std::forward<Ts> (ds)...));
   }
 
   void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
@@ -3469,7 +3469,7 @@
     TRACE_DISPATCH (this, u.format);
     if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
     switch (u.format) {
-    case 1: return_trace (u.format1.dispatch (c, hb_forward<Ts> (ds)...));
+    case 1: return_trace (u.format1.dispatch (c, std::forward<Ts> (ds)...));
     default:return_trace (c->default_return_value ());
     }
   }
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index cf3e1df..d02a3c0 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -2011,14 +2011,14 @@
   private:
   template <typename T, typename ...Ts> auto
   _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN
-  ( obj.get_glyph_alternates (hb_forward<Ts> (ds)...) )
+  ( obj.get_glyph_alternates (std::forward<Ts> (ds)...) )
   template <typename T, typename ...Ts> auto
   _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN
   ( default_return_value () )
   public:
   template <typename T, typename ...Ts> auto
   dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN
-  ( _dispatch (obj, hb_prioritize, hb_forward<Ts> (ds)...) )
+  ( _dispatch (obj, hb_prioritize, std::forward<Ts> (ds)...) )
 };
 
 /**
diff --git a/src/hb-sanitize.hh b/src/hb-sanitize.hh
index 56c4601..2e536c7 100644
--- a/src/hb-sanitize.hh
+++ b/src/hb-sanitize.hh
@@ -145,14 +145,14 @@
   private:
   template <typename T, typename ...Ts> auto
   _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN
-  ( obj.sanitize (this, hb_forward<Ts> (ds)...) )
+  ( obj.sanitize (this, std::forward<Ts> (ds)...) )
   template <typename T, typename ...Ts> auto
   _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN
-  ( obj.dispatch (this, hb_forward<Ts> (ds)...) )
+  ( obj.dispatch (this, std::forward<Ts> (ds)...) )
   public:
   template <typename T, typename ...Ts> auto
   dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN
-  ( _dispatch (obj, hb_prioritize, hb_forward<Ts> (ds)...) )
+  ( _dispatch (obj, hb_prioritize, std::forward<Ts> (ds)...) )
 
 
   void init (hb_blob_t *b)
diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh
index 7212d98..7b83fe1 100644
--- a/src/hb-serialize.hh
+++ b/src/hb-serialize.hh
@@ -189,8 +189,8 @@
   { return check_success (!hb_deref (obj).in_error ()); }
 
   template <typename T1, typename... Ts> bool propagate_error (T1 &&o1, Ts&&... os)
-  { return propagate_error (hb_forward<T1> (o1)) &&
-	   propagate_error (hb_forward<Ts> (os)...); }
+  { return propagate_error (std::forward<T1> (o1)) &&
+	   propagate_error (std::forward<Ts> (os)...); }
 
   /* To be called around main operation. */
   template <typename Type>
@@ -376,7 +376,7 @@
       err (HB_SERIALIZE_ERROR_OTHER);
 
     link.width = sizeof (T);
-    link.is_signed = hb_is_signed (hb_unwrap_type (T));
+    link.is_signed = std::is_signed<hb_unwrap_type (T)>::value;
     link.whence = (unsigned) whence;
     link.position = (const char *) &ofs - current->head;
     link.bias = bias;
@@ -494,7 +494,7 @@
 
   template <typename Type, typename ...Ts> auto
   _copy (const Type &src, hb_priority<1>, Ts&&... ds) HB_RETURN
-  (Type *, src.copy (this, hb_forward<Ts> (ds)...))
+  (Type *, src.copy (this, std::forward<Ts> (ds)...))
 
   template <typename Type> auto
   _copy (const Type &src, hb_priority<0>) -> decltype (&(hb_declval<Type> () = src))
@@ -509,16 +509,16 @@
    * instead of memcpy(). */
   template <typename Type, typename ...Ts>
   Type *copy (const Type &src, Ts&&... ds)
-  { return _copy (src, hb_prioritize, hb_forward<Ts> (ds)...); }
+  { return _copy (src, hb_prioritize, std::forward<Ts> (ds)...); }
   template <typename Type, typename ...Ts>
   Type *copy (const Type *src, Ts&&... ds)
-  { return copy (*src, hb_forward<Ts> (ds)...); }
+  { return copy (*src, std::forward<Ts> (ds)...); }
 
   template<typename Iterator,
 	   hb_requires (hb_is_iterator (Iterator)),
 	   typename ...Ts>
   void copy_all (Iterator it, Ts&&... ds)
-  { for (decltype (*it) _ : it) copy (_, hb_forward<Ts> (ds)...); }
+  { for (decltype (*it) _ : it) copy (_, std::forward<Ts> (ds)...); }
 
   template <typename Type>
   hb_serialize_context_t& operator << (const Type &obj) & { embed (obj); return *this; }
@@ -546,10 +546,10 @@
 
   template <typename Type, typename ...Ts>
   Type *extend (Type *obj, Ts&&... ds)
-  { return extend_size (obj, obj->get_size (hb_forward<Ts> (ds)...)); }
+  { return extend_size (obj, obj->get_size (std::forward<Ts> (ds)...)); }
   template <typename Type, typename ...Ts>
   Type *extend (Type &obj, Ts&&... ds)
-  { return extend (hb_addressof (obj), hb_forward<Ts> (ds)...); }
+  { return extend (hb_addressof (obj), std::forward<Ts> (ds)...); }
 
   /* Output routines. */
   hb_bytes_t copy_bytes () const
diff --git a/src/hb-set.hh b/src/hb-set.hh
index 437e234..8841427 100644
--- a/src/hb-set.hh
+++ b/src/hb-set.hh
@@ -42,9 +42,22 @@
   ~hb_sparseset_t () { fini (); }
 
   hb_sparseset_t (const hb_sparseset_t& other) : hb_sparseset_t () { set (other); }
-  void operator= (const hb_sparseset_t& other) { set (other); }
-  // TODO Add move construtor/assign
-  // TODO Add constructor for Iterator
+  hb_sparseset_t (hb_sparseset_t&& other) : hb_sparseset_t () { s = std::move (other.s); }
+  hb_sparseset_t& operator= (const hb_sparseset_t& other) { set (other); return *this; }
+  hb_sparseset_t& operator= (hb_sparseset_t&& other) { hb_swap (*this, other); return *this; }
+  friend void swap (hb_sparseset_t& a, hb_sparseset_t& b) { hb_swap (a.s, b.s); }
+
+  hb_sparseset_t (std::initializer_list<hb_codepoint_t> lst) : hb_sparseset_t ()
+  {
+    for (auto&& item : lst)
+      add (item);
+  }
+  template <typename Iterable,
+	    hb_requires (hb_is_iterable (Iterable))>
+  hb_sparseset_t (const Iterable &o) : hb_sparseset_t ()
+  {
+    hb_copy (o, *this);
+  }
 
   void init_shallow () { s.init (); }
   void init ()
@@ -140,7 +153,18 @@
   operator iter_t () const { return iter (); }
 };
 
-struct hb_set_t : hb_sparseset_t<hb_bit_set_invertible_t> {};
+struct hb_set_t : hb_sparseset_t<hb_bit_set_invertible_t>
+{
+  hb_set_t () = default;
+  ~hb_set_t () = default;
+  hb_set_t (hb_set_t& o) = default;
+  hb_set_t& operator= (const hb_set_t& other) = default;
+  hb_set_t& operator= (hb_set_t&& other) = default;
+  hb_set_t (std::initializer_list<hb_codepoint_t> lst) : hb_sparseset_t<hb_bit_set_invertible_t> (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) {}
+};
 
 static_assert (hb_set_t::INVALID == HB_SET_VALUE_INVALID, "");
 
diff --git a/src/hb-subset.hh b/src/hb-subset.hh
index c9b01c6..98c5f06 100644
--- a/src/hb-subset.hh
+++ b/src/hb-subset.hh
@@ -45,14 +45,14 @@
   private:
   template <typename T, typename ...Ts> auto
   _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN
-  ( obj.subset (this, hb_forward<Ts> (ds)...) )
+  ( obj.subset (this, std::forward<Ts> (ds)...) )
   template <typename T, typename ...Ts> auto
   _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN
-  ( obj.dispatch (this, hb_forward<Ts> (ds)...) )
+  ( obj.dispatch (this, std::forward<Ts> (ds)...) )
   public:
   template <typename T, typename ...Ts> auto
   dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN
-  ( _dispatch (obj, hb_prioritize, hb_forward<Ts> (ds)...) )
+  ( _dispatch (obj, hb_prioritize, std::forward<Ts> (ds)...) )
 
   hb_blob_t *source_blob;
   hb_subset_plan_t *plan;
diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index 44c174d..b0a1e5e 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -38,10 +38,23 @@
   typedef Type item_t;
   static constexpr unsigned item_size = hb_static_size (Type);
 
-  hb_vector_t ()  { init (); }
-  hb_vector_t (const hb_vector_t &o)
+  hb_vector_t () = default;
+  hb_vector_t (std::initializer_list<Type> lst) : hb_vector_t ()
   {
-    init ();
+    alloc (lst.size ());
+    for (auto&& item : lst)
+      push (item);
+  }
+  template <typename Iterable,
+	    hb_requires (hb_is_iterable (Iterable))>
+  hb_vector_t (const Iterable &o) : hb_vector_t ()
+  {
+    if (hb_iter (o).is_random_access_iterator)
+      alloc (hb_len (hb_iter (o)));
+    hb_copy (o, *this);
+  }
+  hb_vector_t (const hb_vector_t &o) : hb_vector_t ()
+  {
     alloc (o.length);
     hb_copy (o, *this);
   }
@@ -55,11 +68,11 @@
   ~hb_vector_t () { fini (); }
 
   private:
-  int allocated; /* == -1 means allocation failed. */
+  int allocated = 0; /* == -1 means allocation failed. */
   public:
-  unsigned int length;
+  unsigned int length = 0;
   public:
-  Type *arrayZ;
+  Type *arrayZ = nullptr;
 
   void init ()
   {
@@ -103,11 +116,7 @@
   }
   hb_vector_t& operator = (hb_vector_t &&o)
   {
-    fini ();
-    allocated = o.allocated;
-    length = o.length;
-    arrayZ = o.arrayZ;
-    o.init ();
+    hb_swap (*this, o);
     return *this;
   }
 
@@ -141,7 +150,7 @@
 
   /* Sink interface. */
   template <typename T>
-  hb_vector_t& operator << (T&& v) { push (hb_forward<T> (v)); return *this; }
+  hb_vector_t& operator << (T&& v) { push (std::forward<T> (v)); return *this; }
 
   hb_array_t<      Type> as_array ()       { return hb_array (arrayZ, length); }
   hb_array_t<const Type> as_array () const { return hb_array (arrayZ, length); }
@@ -189,7 +198,7 @@
       // the created copy to leak memory since we won't have stored a
       // reference to it.
       return p;
-    *p = hb_forward<T> (v);
+    *p = std::forward<T> (v);
     return p;
   }
 
@@ -246,7 +255,7 @@
   Type pop ()
   {
     if (!length) return Null (Type);
-    return hb_move (arrayZ[--length]); /* Does this move actually work? */
+    return std::move (arrayZ[--length]); /* Does this move actually work? */
   }
 
   void remove (unsigned int i)
@@ -302,6 +311,19 @@
 template <typename Type>
 struct hb_sorted_vector_t : hb_vector_t<Type>
 {
+  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<Type> lst) : hb_vector_t<Type> (lst) {}
+  template <typename Iterable,
+	    hb_requires (hb_is_iterable (Iterable))>
+  hb_sorted_vector_t (const Iterable &o) : hb_vector_t<Type> (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<Type>&) (a), (hb_vector_t<Type>&) (b)); }
+
   hb_sorted_array_t<      Type> as_array ()       { return hb_sorted_array (this->arrayZ, this->length); }
   hb_sorted_array_t<const Type> as_array () const { return hb_sorted_array (this->arrayZ, this->length); }
 
diff --git a/src/meson.build b/src/meson.build
index db4208f..bda44c6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -488,10 +488,12 @@
     'test-repacker': ['test-repacker.cc', 'hb-static.cc'],
     'test-priority-queue': ['test-priority-queue.cc', 'hb-static.cc'],
     'test-iter': ['test-iter.cc', 'hb-static.cc'],
-    'test-meta': ['test-meta.cc', 'hb-static.cc'],
+    'test-map': ['test-map.cc', 'hb-static.cc'],
     'test-number': ['test-number.cc', 'hb-number.cc'],
     'test-ot-tag': ['hb-ot-tag.cc'],
+    'test-set': ['test-set.cc', 'hb-static.cc'],
     'test-unicode-ranges': ['test-unicode-ranges.cc'],
+    'test-vector': ['test-vector.cc', 'hb-static.cc'],
     'test-bimap': ['test-bimap.cc', 'hb-static.cc'],
   }
   foreach name, source : compiled_tests
diff --git a/src/test-map.cc b/src/test-map.cc
new file mode 100644
index 0000000..5761cc8
--- /dev/null
+++ b/src/test-map.cc
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 2021  Behdad Esfahbod
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+
+#include "hb.hh"
+#include "hb-map.hh"
+
+
+int
+main (int argc, char **argv)
+{
+
+  /* Test copy constructor. */
+  {
+    hb_map_t v1;
+    v1.set (1, 2);
+    hb_map_t v2 {v1};
+    assert (v1.get_population () == 1);
+    assert (v2.get_population () == 1);
+    assert (v1[1] == 2);
+    assert (v2[1] == 2);
+  }
+
+  /* Test copy assignment. */
+  {
+    hb_map_t v1;
+    v1.set (1, 2);
+    hb_map_t v2 = v1;
+    assert (v1.get_population () == 1);
+    assert (v2.get_population () == 1);
+    assert (v1[1] == 2);
+    assert (v2[1] == 2);
+  }
+
+  /* Test move constructor. */
+  {
+    hb_map_t v {hb_map_t {}};
+  }
+
+  /* Test move assignment. */
+  {
+    hb_map_t v;
+    v = hb_map_t {};
+  }
+
+  /* Test initializing from iterable. */
+  {
+    hb_map_t s;
+
+    s.set (1, 2);
+    s.set (3, 4);
+
+    hb_map_t v (s);
+
+    assert (v.get_population () == 2);
+  }
+
+  /* Test initializing from iterator. */
+  {
+    hb_map_t s;
+
+    s.set (1, 2);
+    s.set (3, 4);
+
+    hb_map_t v (hb_iter (s));
+
+    assert (v.get_population () == 2);
+  }
+
+  /* Test initializing from initializer list and swapping. */
+  {
+    using pair_t = hb_pair_t<hb_codepoint_t, hb_codepoint_t>;
+    hb_map_t v1 {pair_t{1,2}, pair_t{4,5}};
+    hb_map_t v2 {pair_t{3,4}};
+    hb_swap (v1, v2);
+    assert (v1.get_population () == 1);
+    assert (v2.get_population () == 2);
+  }
+
+  return 0;
+}
diff --git a/src/test-meta.cc b/src/test-meta.cc
deleted file mode 100644
index 9436b90..0000000
--- a/src/test-meta.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright © 2019  Facebook, Inc.
- *
- *  This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Facebook Author(s): Behdad Esfahbod
- */
-
-#include "hb.hh"
-#include "hb-meta.hh"
-
-#include <type_traits>
-
-template <typename T> struct U { typedef T type; };
-
-int
-main (int argc, char **argv)
-{
-  static_assert (hb_is_convertible (void, void), "");
-  static_assert (hb_is_convertible (void, const void), "");
-  static_assert (hb_is_convertible (const void, void), "");
-
-  static_assert (hb_is_convertible (int,  int), "");
-  static_assert (hb_is_convertible (char, int), "");
-  static_assert (hb_is_convertible (long, int), "");
-
-  static_assert (hb_is_convertible (int, int), "");
-
-  static_assert (hb_is_convertible (const int, int), "");
-  static_assert (hb_is_convertible (int, const int), "");
-  static_assert (hb_is_convertible (const int, const int), "");
-
-  static_assert (hb_is_convertible (int&, int), "");
-  static_assert (!hb_is_convertible (int, int&), "");
-
-  static_assert (hb_is_convertible (int, const int&), "");
-  static_assert (!hb_is_convertible (const int, int&), "");
-  static_assert (hb_is_convertible (const int, const int&), "");
-  static_assert (hb_is_convertible (int&, const int), "");
-  static_assert (hb_is_convertible (const int&, int), "");
-  static_assert (hb_is_convertible (const int&, const int), "");
-  static_assert (hb_is_convertible (const int&, const int), "");
-
-  struct X {};
-  struct Y : X {};
-
-  static_assert (hb_is_convertible (const X &, const X), "");
-  static_assert (hb_is_convertible (X &, const X), "");
-  static_assert (hb_is_convertible (X &, const X &), "");
-  static_assert (hb_is_convertible (X, const X &), "");
-  static_assert (hb_is_convertible (const X, const X &), "");
-  static_assert (!hb_is_convertible (const X, X &), "");
-  static_assert (!hb_is_convertible (X, X &), "");
-  static_assert (hb_is_convertible (X &, X &), "");
-
-  static_assert (hb_is_convertible (int&, long), "");
-  static_assert (!hb_is_convertible (int&, long&), "");
-
-  static_assert (hb_is_convertible (int *, int *), "");
-  static_assert (hb_is_convertible (int *, const int *), "");
-  static_assert (!hb_is_convertible (const int *, int *), "");
-  static_assert (!hb_is_convertible (int *, long *), "");
-  static_assert (hb_is_convertible (int *, void *), "");
-  static_assert (!hb_is_convertible (void *, int *), "");
-
-  static_assert (hb_is_base_of (void, void), "");
-  static_assert (hb_is_base_of (void, int), "");
-  static_assert (!hb_is_base_of (int, void), "");
-
-  static_assert (hb_is_base_of (int, int), "");
-  static_assert (hb_is_base_of (const int, int), "");
-  static_assert (hb_is_base_of (int, const int), "");
-
-  static_assert (hb_is_base_of (X, X), "");
-  static_assert (hb_is_base_of (X, Y), "");
-  static_assert (hb_is_base_of (const X, Y), "");
-  static_assert (hb_is_base_of (X, const Y), "");
-  static_assert (!hb_is_base_of (Y, X), "");
-
-  static_assert (hb_is_constructible (int), "");
-  static_assert (hb_is_constructible (int, int), "");
-  static_assert (hb_is_constructible (int, char), "");
-  static_assert (hb_is_constructible (int, long), "");
-  static_assert (!hb_is_constructible (int, X), "");
-  static_assert (!hb_is_constructible (int, int, int), "");
-  static_assert (hb_is_constructible (X), "");
-  static_assert (!hb_is_constructible (X, int), "");
-  static_assert (hb_is_constructible (X, X), "");
-  static_assert (!hb_is_constructible (X, X, X), "");
-  static_assert (hb_is_constructible (X, Y), "");
-  static_assert (!hb_is_constructible (Y, X), "");
-
-  static_assert (hb_is_trivially_default_constructible (X), "");
-  static_assert (hb_is_trivially_default_constructible (Y), "");
-  static_assert (hb_is_trivially_copy_constructible (X), "");
-  static_assert (hb_is_trivially_copy_constructible (Y), "");
-  static_assert (hb_is_trivially_move_constructible (X), "");
-  static_assert (hb_is_trivially_move_constructible (Y), "");
-  static_assert (hb_is_trivially_destructible (Y), "");
-
-  static_assert (hb_is_trivially_copyable (int), "");
-  static_assert (hb_is_trivially_copyable (X), "");
-  static_assert (hb_is_trivially_copyable (Y), "");
-
-  static_assert (hb_is_trivial (int), "");
-  static_assert (hb_is_trivial (X), "");
-  static_assert (hb_is_trivial (Y), "");
-
-  static_assert (hb_is_signed (hb_unwrap_type (U<U<U<int>>>)), "");
-  static_assert (hb_is_unsigned (hb_unwrap_type (U<U<U<U<unsigned>>>>)), "");
-
-  /* TODO Add more meaningful tests. */
-
-  return 0;
-}
diff --git a/src/test-set.cc b/src/test-set.cc
new file mode 100644
index 0000000..286f1a9
--- /dev/null
+++ b/src/test-set.cc
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2021  Behdad Esfahbod
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+
+#include "hb.hh"
+#include "hb-set.hh"
+
+
+int
+main (int argc, char **argv)
+{
+
+  /* Test copy constructor. */
+  {
+    hb_set_t v1 {1, 2};
+    hb_set_t v2 {v1};
+    assert (v1.get_population () == 2);
+    assert (v2.get_population () == 2);
+  }
+
+  /* Test copy assignment. */
+  {
+    hb_set_t v1 {1, 2};
+    hb_set_t v2 = v1;
+    assert (v1.get_population () == 2);
+    assert (v2.get_population () == 2);
+  }
+
+  /* Test move constructor. */
+  {
+    hb_set_t v {hb_set_t {1, 2}};
+    assert (v.get_population () == 2);
+  }
+
+  /* Test move assignment. */
+  {
+    hb_set_t v;
+    v = hb_set_t {1, 2};
+    assert (v.get_population () == 2);
+  }
+
+  /* Test initializing from iterable. */
+  {
+    hb_set_t s;
+
+    s.add (18);
+    s.add (12);
+
+    hb_set_t v (s);
+
+    assert (v.get_population () == 2);
+  }
+
+  /* Test initializing from iterator. */
+  {
+    hb_set_t s;
+
+    s.add (18);
+    s.add (12);
+
+    hb_set_t v (hb_iter (s));
+
+    assert (v.get_population () == 2);
+  }
+
+  /* Test initializing from initializer list and swapping. */
+  {
+    hb_set_t v1 {1, 2, 3};
+    hb_set_t v2 {4, 5};
+    hb_swap (v1, v2);
+    assert (v1.get_population () == 2);
+    assert (v2.get_population () == 3);
+  }
+
+  return 0;
+}
diff --git a/src/test-vector.cc b/src/test-vector.cc
new file mode 100644
index 0000000..6418a84
--- /dev/null
+++ b/src/test-vector.cc
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 2021  Behdad Esfahbod
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+
+#include "hb.hh"
+#include "hb-vector.hh"
+#include "hb-set.hh"
+
+
+int
+main (int argc, char **argv)
+{
+
+  /* Test copy constructor. */
+  {
+    hb_vector_t<int> v1 {1, 2};
+    hb_vector_t<int> v2 {v1};
+    hb_vector_t<int> V2 {v1};
+    assert (v1.length == 2);
+    assert (v1[0] == 1);
+    assert (v1[1] == 2);
+    assert (v2.length == 2);
+    assert (v2[0] == 1);
+    assert (v2[1] == 2);
+  }
+
+  /* Test copy assignment. */
+  {
+    hb_vector_t<int> v1 {1, 2};
+    hb_vector_t<int> v2 = v1;
+    hb_vector_t<int> V2 = v1;
+    assert (v1.length == 2);
+    assert (v1[0] == 1);
+    assert (v1[1] == 2);
+    assert (v2.length == 2);
+    assert (v2[0] == 1);
+    assert (v2[1] == 2);
+  }
+
+  /* Test move constructor. */
+  {
+    hb_vector_t<int> v {hb_vector_t<int> {1, 2}};
+    hb_vector_t<int> V {hb_vector_t<int> {1, 2}};
+    assert (v.length == 2);
+    assert (v[0] == 1);
+    assert (v[1] == 2);
+  }
+
+  /* Test move assignment. */
+  {
+    hb_vector_t<int> v;
+    hb_sorted_vector_t<int> V;
+    v = hb_vector_t<int> {1, 2};
+    V = hb_sorted_vector_t<int> {1, 2};
+    assert (v.length == 2);
+    assert (v[0] == 1);
+    assert (v[1] == 2);
+  }
+
+  /* Test initializing from iterable. */
+  {
+    hb_set_t s;
+
+    s.add (18);
+    s.add (12);
+
+    hb_vector_t<int> v (s);
+    hb_sorted_vector_t<int> V (s);
+
+    assert (v.length == 2);
+    assert (V.length == 2);
+    assert (v[0] == 12);
+    assert (V[0] == 12);
+    assert (v[1] == 18);
+    assert (V[1] == 18);
+  }
+
+  /* Test initializing from iterator. */
+  {
+    hb_set_t s;
+
+    s.add (18);
+    s.add (12);
+
+    hb_vector_t<int> v (hb_iter (s));
+    hb_vector_t<int> V (hb_iter (s));
+
+    assert (v.length == 2);
+    assert (V.length == 2);
+    assert (v[0] == 12);
+    assert (V[0] == 12);
+    assert (v[1] == 18);
+    assert (V[1] == 18);
+  }
+
+  /* Test initializing from initializer list and swapping. */
+  {
+    hb_vector_t<int> v1 {1, 2, 3};
+    hb_vector_t<int> v2 {4, 5};
+    hb_swap (v1, v2);
+    assert (v1.length == 2);
+    assert (v1[0] == 4);
+    assert (v2.length == 3);
+    assert (v2[2] == 3);
+  }
+
+  /* Test initializing sorted-vector from initializer list and swapping. */
+  {
+    hb_sorted_vector_t<int> v1 {1, 2, 3};
+    hb_sorted_vector_t<int> v2 {4, 5};
+    hb_swap (v1, v2);
+    assert (v1.length == 2);
+    assert (v1[0] == 4);
+    assert (v2.length == 3);
+    assert (v2[2] == 3);
+  }
+
+  return 0;
+}