以下のコードはVS2010でうまくコンパイルされますが、gcc 4.6.1でコンパイルしたくありません。
#ifndef IS_CHAR_H_INCLUDED
#define IS_CHAR_H_INCLUDED
#include
template
struct Is_Char_
{
enum {value = false};
};
template<>
struct Is_Char_
{
enum {value = true};
};
template<>
struct Is_Char_
{
enum {value = true};
};
template<>
struct Is_Char_
{
enum {value = true};
};
template
struct Is_Char : Is_Char_::type>
{
};
#endif//IS_CHAR_H_INCLUDED
#ifndef PROMOTE_H_INCLUDED
#define PROMOTE_H_INCLUDED
#include
#include
#include
#include
#include
#include
//#include "Is_Char.h" doesn't have to be here this file is pasted above
/*Promotes Integer type to one up in size range*/
template
struct Promote
{
static_assert(std::is_integral::value,"Non Integer type is not allowed.");
/*Check correct type - depending on Integer being signed or unsigned*/
typedef typename std::conditional::value,
boost::mpl::vector,
boost::mpl::vector
>::type types;
/*
Find this type from the list above - substituting Integer for signed or unsigned char iff Integer is of type char
*/
typedef typename boost::mpl::find::value,
typename std::conditional::value,signed char,unsigned char>::type, Integer>::type>::type this_type;
/*If Integer is int and if size of it is == to long promote int to long long (iterate to next element twice)*/
typedef typename boost::mpl::eval_if::value || std::is_same::value)
&& (sizeof(int) == sizeof(long)))>,
boost::mpl::next::type>,
boost::mpl::next<this_type>
>::type next_type;
/*Check if iterator points within range or if one pass end which means that Integer was u/long long*/
typedef typename std::conditional::type,next_type>::value,Integer,typename boost::mpl::deref::type>::type type;
};
#endif//PROMOTE_H_INCLUDED