【发布时间】:2011-10-22 10:19:52
【问题描述】:
此代码在 Visual C++ 11 Developer Preview 中可以正常编译,但在 gcc 4.6.1 中无法编译。
如何使它对后者“可编译”?
#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
然后在main中:
cout << typeid( Promote<int>::type).name() ;
【问题讨论】: