Haruyuki Mohri

毛利春幸のブログです。

Let template of TNotifyEvent<TObject* >

TNotifyEvent is without the need for templates.

Because the event template unaware.

typedef void __fastcall (__closure *TNotifyEvent)(System::TObject* Sender);

OK remain now.

Making a template with TNotifyEvent

TNotifyEvent is set to TNotifyEvent1(New Name)

template <class T>
using TNotifyEvent1 = void __fastcall (__closure *)(T Sender);

こんな事が可能になる

TNotifyEvent1<TComponent* > FOnEvent;
void __fastcall TForm1::thread_event(TComponent* Sender)
{
    ....
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
    FOnEvent = thread_event;
}

実装部メソッドもtemplateできると嬉しいのですが。。。

f:id:mojeld:20160727135609g:plain