以下の内容はhttps://amachang.hatenablog.com/entry/20090707/1246943065より取得しました。


boost::is_convertible はどうやってるか

概ね以下のような感じ

template <typename From, typename To>
struct is_convertible_basic_impl
{
    // 2 つの同名関数を作って
    static no_type _m_check(...);
    static yes_type _m_check(To);

    // 関数の戻り値の型を見る(どっちの関数が使われるかを見る)
    static bool value = sizeof( _m_check(From) ) == sizeof(yes_type);
};

これで From 型のオブジェクトが To 型に代入できるかが、コンパイル時に分かるのな
sizeof の以外な使い道。




以上の内容はhttps://amachang.hatenablog.com/entry/20090707/1246943065より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14