Boostを語れゴラァ part5at TECH
Boostを語れゴラァ part5 - 暇つぶし2ch22:デフォルトの名無しさん
07/10/29 14:56:29
>>20
ディスパッチのユーティリティとして使うとか。
boost/type_traits/detail/wrap.hpp とかもあるね。

template <class T> struct type {};

template <class T>
struct tester {
 template <class U> static char (&test(U*))[1];
 template <class U> static char (&test(type<U>*))[2];
 template <class U> static char (&test(...))[3];

 template <class U> static size_t f1(const U&) {
  return sizeof(test<T>(static_cast<U*>(0)));
 }
 template <class U> static size_t f2(const U&) {
  return sizeof(test<T>(static_cast<type<U>*>(0)));
 }
};

struct X {};
struct XX : X {};

tester<X>::f1(X()); // => 1
tester<X>::f1(XX()); // => 1

tester<X>::f2(X()); // => 2
tester<X>::f2(XX()); // => 3



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch