1 /* Test for using ObjC classes as C++ template parameters. */
2 /* Author: Ziemowit Laski <zlaski@apple.com>. */
6 #include <objc/Object.h>
9 #define CHECK_IF(expr) if(!(expr)) abort()
11 @interface Base: Object
15 @interface Derived: Base
21 template <class T> struct Templ
25 Templ(): i(55), m([[T alloc] init]) { count++; }
26 ~Templ() { [m free]; count--; }
30 - (int) meth { return 333; }
33 @implementation Derived
34 - (int) meth { return 666; }
40 Templ<Derived> derived;
41 CHECK_IF(derived.i == 55 && count == 1);
43 CHECK_IF(base.i == 55 && count == 2);
44 CHECK_IF([base.m meth] == 333);
45 CHECK_IF([derived.m meth] == 666);