From 6b6783e1588ebe5772a1edc19552219e9d931bda Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 26 Jan 2019 22:44:09 +0100 Subject: [PATCH] [iter/meta] Fix build on newer clang The mystery failure had to do with SFINAE failure because the template function involved was accessing ::iter_t of a type that was also named iter_t. In this context, apparently: warning: ISO C++ specifies that qualified reference to 'iter_t' is a constructor name rather than a type in this context, despite preceding 'typename' keyword [-Winjected-class-name] We use a new macro, also called hb_iter_t(), to get iterator type of a type. This uses declval/hb_decltype, and has the added benefit that it returns correct type for const vs non-const objects, if they have different iterators. --- src/hb-iter.hh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index da93a5b37..e86e795d1 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -49,10 +49,9 @@ */ /* Base class for all iterators. */ -template +template struct hb_iter_t { - typedef Iter iter_t; typedef Item item_t; static constexpr unsigned item_size = hb_static_size (Item); static constexpr bool is_iterator = true; @@ -92,8 +91,10 @@ struct hb_iter_t void operator = (const hb_iter_t &o HB_UNUSED) {} }; +/* Returns iterator type of a type. */ +#define hb_iter_t(Iterable) decltype (hb_declval (Iterable).iter ()) + #define HB_ITER_USING(Name) \ - using iter_t = typename Name::iter_t; \ using item_t = typename Name::item_t; \ using Name::item_size; \ using Name::is_iterator; \ @@ -227,6 +228,7 @@ struct hb_map_iter_t : Iter it; Proj f; }; + template struct hb_map_iter_factory_t { @@ -234,8 +236,8 @@ struct hb_map_iter_factory_t template - hb_map_iter_t operator () (const Iterable &c) const - { return hb_map_iter_t (c.iter (), f); } + hb_map_iter_t operator () (const Iterable &c) const + { return hb_map_iter_t (c.iter (), f); } private: Proj f; @@ -273,8 +275,8 @@ struct hb_filter_iter_factory_t template - hb_filter_iter_t operator () (const Iterable &c) const - { return hb_filter_iter_t (c.iter (), p, f); } + hb_filter_iter_t operator () (const Iterable &c) const + { return hb_filter_iter_t (c.iter (), p, f); } private: Pred p; @@ -316,9 +318,9 @@ struct hb_zip_iter_t : }; template -inline hb_zip_iter_t +inline hb_zip_iter_t hb_zip (const A& a, const B &b) -{ return hb_zip_iter_t (a.iter (), b.iter ()); } +{ return hb_zip_iter_t (a.iter (), b.iter ()); } /* @@ -330,7 +332,7 @@ template