This code compiles fine with Visual C++ 11 Developer Preview but won't compile with gcc 4.6.1.
How to make it "compilable" for the latter?
#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
and then in main:
cout << typeid( Promote<int>::type).name() ;
Change your include directives:
#include <boost/mpl/vector.hpp>
This will work both on Windows and Unix-type systems.
No other syntax problems detected (but since this is just a template, I have no idea if there are problems when you actually use it).
Edit: with what you add in the main, it compiles with GCC 4.6.1.
Don't forget to #include <typeinfo>
.