以下のコードは、boost MPL ライブラリについて私が本当に理解していない動作を再現しています。
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/plus.hpp>
using namespace boost;
int main() {
typedef mpl::int_<1> one;
typedef mpl::int_<2> two;
typedef mpl::int_<3> three;
// The following line breaks compilation...
// static_assert( is_same< mpl::plus<one,two>::type, three >::type::value, "Not the same type");
// ...while this works
static_assert( mpl::plus<one,two>::type::value == three::value , "Not the same value");
return 0;
}
私が持っている質問は、なぜmpl::plus<one,two>::type
と同じタイプではないのthree
ですか?
C++ Template Meta-Programmingの第 3 章の最後にある演習を解こうとしているときに、この問題に遭遇しました
。私はすでにその中のインクルードをのぞき見しようとしまし<boost/mpl/plus.hpp>
たが、コードが複雑すぎて理解できませんでした。