Boostを語れゴラァ pa ..
[
2ch
|
▼Menu
]
■コピペモード
□
スレを通常表示
□
オプションモード
□このスレッドのURL
■項目テキスト
21:デフォルトの名無しさん 07/10/28 20:11:24 template<class T> T f(); を f<int>(); と呼べない場合があるので template<class T> T g(boost::type<T>); を g(boost::type<int>()); と呼ぶ 22:デフォルトの名無しさん 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
次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
レスジャンプ
mixiチェック!
Twitterに投稿
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch
4273日前に更新/65 KB
担当:undef