I wrote code that looked like the following:
template<typename CocoaWidget>
class Widget : boost::noncopyable
{
private:
CocoaWidget* mCocoaWidget;
public:
Widget()
{
mCocoaWidget = [[CocoaWidget alloc] init];
}
// ...
};
class Button : Widget<NSButton>
{
// ...
};
But that doesn’t work, because Mac Dev Center says:
Objective-C classes, protocols, and
categories cannot be declared inside a
C++ template
So what shall I do now best?
Are you sure you can’t do this (have you tried)?
The quote from Mac Dev Center says you can’t declare an Objective-C class inside a template. What you’re doing, however, is merely declaring a pointer to an Objective-C object inside a template — quite a different thing, and I don’t see a reason why it shouldn’t be allowed (though I have never tried).