読者です 読者をやめる 読者になる 読者になる

Haruyuki Mohri

毛利春幸のブログです。

Try SFINAE in C++Builder XE8

I used the previous try boost::asio.

This program to check whether the class there is a "TObject".

#include <System.Generics.Collections.hpp>
//
template <class T>
bool check_1(typename T::TObject*)
{ return true; }

template <class T>
constexpr bool check_1(...)
{ return false; }

template <class T>
constexpr bool check_object()
{ return check_1<T>(nullptr); }

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    String s;
    if (check_object<System::Generics::Collections::TList__1<int> >())
    { s = "true"; }
    if (check_object<TFmxObject >())
    { s = "true"; }
    if (check_object<std::string >())
    { s = "true"; }
    Caption = s;
}

"std::string" does not have a "TObject".
So it is returned false.