From 790315e0dbc0ce796f0081a60953f74bd3fbdb63 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 9 May 2019 15:31:24 -0700 Subject: [PATCH] [algs] Implement implicit casting between compatible pair types --- src/hb-algs.hh | 5 +++++ src/test-algs.cc | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index dbb0805fc..bbf748e3b 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -217,6 +217,11 @@ struct hb_pair_t hb_pair_t (T1 a, T2 b) : first (a), second (b) {} hb_pair_t (const pair_t& o) : first (o.first), second (o.second) {} + template + operator hb_pair_t () { return hb_pair_t (first, second); } + hb_pair_t reverse () const { return hb_pair_t (second, first); } diff --git a/src/test-algs.cc b/src/test-algs.cc index d6f34d707..774414ad1 100644 --- a/src/test-algs.cc +++ b/src/test-algs.cc @@ -73,5 +73,8 @@ main (int argc, char **argv) z = 3; assert (x == 3); + hb_pair_t xp = hb_pair_t (nullptr, 0); + xp = hb_pair_t (nullptr, 1); + return 0; }