- 109 名前:デフォルトの名無しさん [2007/10/01(月) 02:02:08 ]
- >>99
enable_ifの関数テンプレへの適用で質問。ある条件で2つの関数を呼びわけたいときは、こんな感じにすればいいみたいだけど、 template<typename T> static void foo(T t, typename boost::disable_if<boost::is_same<T,int> >::type* = 0) { } template<typename T> static void foo(T t, typename boost::enable_if<boost::is_same<T,int> >::type* = 0) { // intへの特殊化版 } 3つ以上を呼びわけるにはどうすれば? たとえば、 template<int V> static void boo(typename boost::enable_if_c<V == 0>::type* = 0) { } template<int V> static void boo(typename boost::enable_if_c<V == 1>::type* = 0) { } template<int V> static void boo(typename boost::disable_if_c<V == 0 || V == 1>::type* = 0) { // default } とかだと、default caseな関数の引数が大変なことになってしまうような。 boostスレのほうがいいのかな。。
|

|