使用BOOST_MP11_VERSION宏的示例代码
BOOST_MP11_VERSION宏是Boost C++库中的一个版本宏,用于确定使用的编译器是否支持C++11标准及其后续版本。下面是一段使用BOOST_MP11_VERSION宏的示例代码:
#include <boost/mp11.hpp>
#include <iostream>
template<typename T>
void print_type() {
std::cout << typeid(T).name() << std::endl;
}
int main() {
// 判断编译器是否支持 C++11 版本
#if BOOST_MP11_VERSION < 107000
std::cout << "Your compiler does not support C++11 or later." << std::endl;
return 1;
#else
std::cout << "Your compiler supports C++11 or later." << std::endl;
#endif
// 输出变量类型
print_type<boost::mp11::mp_int<42>>();
print_type<boost::mp11::mp_list<int, float, double>>();
return 0;
}