From: Behdad Esfahbod Date: Thu, 9 May 2019 22:31:24 +0000 (-0700) Subject: [algs] Implement implicit casting between compatible pair types X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=790315e0dbc0ce796f0081a60953f74bd3fbdb63;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [algs] Implement implicit casting between compatible pair types --- diff --git a/src/hb-algs.hh b/src/hb-algs.hh index dbb0805..bbf748e 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 d6f34d7..774414a 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; }