mpl::lambda の注意点
次のコードはエラーになります。
// placeholders を mpl::vector で使用する typedef mpl::lambda<mpl::vector<_1, _2, _3> >::type triple; typedef triple::apply<triple, int, int, int>::type int_int_int; // mpl::equal を使用する(placeholders を使用したデフォルト引数が原因?) typedef mpl::lambda<mpl::equal<mpl::vector<int,int>, _1> >::type is_vector_int_int; typedef mpl::apply<is_vector_int_int, mpl::vector<int, int> >::type true_;
[対処法]
// mpl::vector3 を使用する typedef mpl::lambda<mpl::vector3<_1, _2, _3> >::type triple; typedef triple::apply<triple, int, int, int>::type int_int_int; // mpl::equal をラップする template<typename T, typename U> struct equal : mpl::equal<T, U, boost::is_same<_1, _2> >{}; typedef mpl::lambda<equal<mpl::vector<int, int>, _1> >::type is_vector_int_int; typedef mpl::apply<is_vector_int_int, mpl::vector<int, int> >::type true_;
原因がよく分かりません……。
うーん、デフォルトテンプレート引数?placeholders?
とりあえず、結構はまりやすいと思うので(特に mpl::equal なんか)を使用する際はご注意を。