아래의 코드는 정말 부스트 MPL 라이브러리의 이해하지 못하는 행동 재생하기 :`mpl :: plus <mpl :: int_ <1>, mpl :: int_ > :: type`은`mpl :: int_ <3>`과 같은 타입이 아닙니까?
내가 가진 질문은#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>
을 들여다 보았지만 거기에는 그 내용이 포함되어 있지만 코드가 너무 복잡해서 이해할 수 없었다.
덕분에'템플릿 구조체 인쇄;'팁! –
Massimiliano
@Massimiliano'mpl :: print'도 있지만, 적어도'gcc'에서는 문제가있는 것으로 보입니다. 컴파일을 중단하지 않는 것이 훨씬 더 좋을 것입니다. – pmr
을 sidenote로 사용하기 위해이 si는 부스트 Trac에 문제로 등록되었습니다. 그래서 우리는 그것이 문제라는 것을 압니다 :) –