2 // { dg-options "-O2" }
7 virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
8 unsigned __outer) const;
12 template< typename VALUE_T, typename TYPE >
15 typedef VALUE_T *Value_type;
17 typedef TYPE *Head_type;
18 typedef TYPE Item_type;
21 template< typename POLICY >
25 typedef typename POLICY::Value_type Value_type;
28 typedef typename POLICY::Type Internal_type;
30 typedef typename POLICY::Value_type value_type;
31 typedef typename POLICY::Value_type Value_type;
32 Value_type operator -> () const { return static_cast<Value_type>(*_c); }
35 Iterator begin() { return Iterator(); }
36 Iterator end() { return Iterator(); }
37 typename POLICY::Head_type _f;
40 template<typename ELEM_TYPE> class H_list_item_t { };
42 template< typename T, typename POLICY >
43 class H_list : public List<POLICY>
46 typedef typename POLICY::Item_type Item;
47 typedef List<POLICY> Base;
48 typedef typename Base::Iterator Iterator;
49 Iterator insert(T *e, Iterator const &pred)
52 *x = static_cast<Item*>(e);
57 template< typename T >
58 struct H_list_t : H_list<T, List_policy< T, H_list_item_t<T> > >
60 H_list_t(bool b) : H_list<T, List_policy< T, H_list_item_t<T> > >(b) {}
63 template< typename BASE, typename MATCH_RESULT >
64 struct Type_matcher : H_list_item_t<BASE>
66 explicit Type_matcher(std::type_info const *type);
67 typedef MATCH_RESULT Match_result;
70 std::type_info *_type;
71 typedef H_list_t<BASE> List;
72 typedef typename List::Iterator Iterator;
73 static List _for_type;
76 template< typename BASE, typename MR >
77 Type_matcher<BASE, MR>::Type_matcher(std::type_info const *t)
79 Iterator c = _for_type.begin();
80 t->__do_catch(c->_type, 0, 0);
81 _for_type.insert(static_cast<BASE*>(this), _for_type.begin());
84 template< typename VI, typename HW >
85 class Fa : public Type_matcher<Fa<VI, HW>, VI*>
88 typedef Fa<VI, HW> Self;
89 virtual VI *do_match(HW *f) = 0;
90 explicit Fa(std::type_info const *type) : Type_matcher<Self, VI*>(type) {}
94 typedef Fa<Res, Res> R_fac;
96 template< typename VI, typename HW_BASE, typename HW, typename BASE >
97 class Fa_t : public BASE
100 Fa_t() : BASE(&typeid(HW)) {}
101 VI *do_match(HW_BASE *) { return 0; }
104 template< typename VI, typename HW >
105 class Resource_factory_t : public Fa_t<VI, Res, HW, R_fac > {};
109 class Foo3 : public Res {};
110 Resource_factory_t<Foo3, Foo> _x;