您可能会丢失一些标题(这可能取决于 boost 的确切版本——我没有那个可用的标题)。这无法正确编译:
#include <boost/mpl/int.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/assert.hpp>
int main()
{
BOOST_MPL_ASSERT(( boost::mpl::equal_to< boost::mpl::long_<10>, boost::mpl::int_<11> > ));
}
输出是:
# g++ -Wall t.cpp
t.cpp: In function ‘int main()’:
t.cpp:8:2: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::mpl::equal_to<mpl_::long_<10l>, mpl_::int_<11> >::************)’
如果没有正确的头文件,就会发生其他各种不相关的编译错误。
如果您不想要命名空间限定符,您可以执行以下操作:
#include <boost/mpl/int.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/assert.hpp>
using namespace boost; // brings boost:: into scope
int main()
{
BOOST_MPL_ASSERT(( mpl::equal_to< mpl::long_<10>, mpl::int_<11> > ));
}
甚至:
#include <boost/mpl/int.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/assert.hpp>
using namespace boost::mpl; // brings boost::mpl:: in scope
int main()
{
BOOST_MPL_ASSERT(( equal_to< long_<10>, int_<11> > ));
}