Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6733575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:47:08+00:00 2026-05-26T10:47:08+00:00

This code below compiles fine with VS2010 but doesn’t want to compile with gcc

  • 0

This code below compiles fine with VS2010 but doesn’t want to compile with gcc 4.6.1.:

#ifndef IS_CHAR_H_INCLUDED
#define IS_CHAR_H_INCLUDED
#include <type_traits>

template<class Int_T>
struct Is_Char_
{
    enum {value = false};
};

template<>
struct Is_Char_<char>
{
    enum {value = true};
};

template<>
struct Is_Char_<unsigned char>
{
    enum {value = true};
};

template<>
struct Is_Char_<signed char>
{
    enum {value = true};
};

template<class Int_T>
struct Is_Char : Is_Char_<typename std::remove_cv<Int_T>::type>
{

};

#endif // IS_CHAR_H_INCLUDED

#ifndef PROMOTE_H_INCLUDED
#define PROMOTE_H_INCLUDED
#include <type_traits>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/find.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/end.hpp>
   //#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<class Integer>
struct Promote
{
    static_assert(std::is_integral<Integer>::value,"Non Integer type is not allowed.");
    /*Check correct type - depending on Integer being signed or unsigned*/
    typedef typename std::conditional<std::is_signed<Integer>::value,
                                boost::mpl::vector<signed char,short,int,long,long long>,
    boost::mpl::vector<unsigned char,unsigned short,unsigned int,long,long long>
                                     >::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<types,
    typename std::conditional<Is_Char<Integer>::value,
    typename std::conditional<std::is_signed<Integer>::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<boost::mpl::bool_<((std::is_same<Integer,int>::value || std::is_same<Integer,unsigned int>::value)
                                                                && (sizeof(int) == sizeof(long)))>,
                                         boost::mpl::next<typename boost::mpl::next<this_type>::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<std::is_same<typename boost::mpl::end<types>::type,next_type>::value,Integer,typename boost::mpl::deref<next_type>::type>::type type;
};

#endif // PROMOTE_H_INCLUDED
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:47:08+00:00Added an answer on May 26, 2026 at 10:47 am

    My guess is that you’re not specifying --std=c++0x when compiling, so C++11 features such as std::is_integral<> aren’t available. Your code compiles for me when I use that option.

    UPDATE: now that you’ve shown the compiler output, the problem is that you’ve enabled just about every possible warning, and also set -Wpedantic-errors to treat some of them as errors. Many of these warnings are triggered by perfectly sensible code, and most authors (including Boost) won’t have taken the time to fix or work around all of them.

    You should certainly remove -Wpedantic-errors, unless you have a particular requirement that no code should ever use compiler-specific extensions; in that case, you probably can’t use Boost. It would probably be a good idea to disable some of the less useful warnings too – you can’t fix the ones that Boost generates, so all they do is make it harder to spot genuine warnings about your code. I generally aim to compile cleanly with -Wall -Wextra.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can this code compile? The code below in the operator int CAN access
Basically this code below returns the right information, but I need to add the
i want to put the id into the colorbox below this code nom works
This code compiles, but no surprises, it fails while linking (no main found): Listing
This code below is for executing ls -l | wc -l. In the code,
This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
i am using this code below to dynamically capture the name of the button
I have this code below. As you can see I am passing two variables
Hi I'm using this code below to let a user draw their signature on
I have this javascript code below that uses jquery, it is suppoed to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.