- 249 名前:245 mailto:sage [2008/01/29(火) 13:41:34 ]
- おかしいな。VC9だとhas_xxxが通らない。
自分で書いてみても、やはり通らない。 こんな風にSFINAEを使ってやればできるはずなんだけど。 struct BjarneStroustrup { void hage() ; } ; struct Others { void fusafusa() ; } ; template < typename T > struct has_hage { struct Yes { char a[1] ; } ; struct No { char a[2] ; } ; template < typename Y > static Yes test(typename Y::hage const *) ; template < typename Y > static No test(...) ; static bool const value = ( sizeof( test<T>(0) ) == 1 ) ; } ; BOOST_STATIC_ASSERT(( has_hage<BjarneStroustrup>::value )) ; BOOST_STATIC_ASSERT(( has_hage<Others>::value )) ;
|

|