2
此代码与Visual C++ 11 Developer Preview编译良好,但不会使用gcc 4.6.1进行编译。升级或不升级 - 这是questiion
如何使后者“可编译”?
#ifndef PROMOTE_H_INCLUDED
#define PROMOTE_H_INCLUDED
#include <boost\mpl\vector.hpp>
#include <boost\mpl\find.hpp>
#include <boost\mpl\next.hpp>
#include <boost\mpl\deref.hpp>
namespace mpl = boost::mpl;
template<class Integral>
struct Promote
{
typedef mpl::vector<char,short,int,long,long long> types;
typedef typename mpl::find<types,Integral>::type this_type;
typedef typename mpl::next<this_type>::type next_type;
typedef typename mpl::deref<next_type>::type type;
};
#endif // PROMOTE_H_INCLUDED
,然后在主:
cout << typeid(Promote<int>::type).name() ;
很好的发现,我永远不会记得哪个斜杠是'正确的'。现在确实有效。谢谢。 – smallB
你会经常在Windows上使用'/',但在基于Unix的系统上,你基本上从不会使用任何工具来使用\。 (顺便说一句,包含指令是如何处理的,我相信是实现定义的,所以都不是安全的。) – Mat