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

  • SEARCH
  • Home
  • 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 8445379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:38:38+00:00 2026-06-10T09:38:38+00:00

I have code, that compiles and runs as expected in gcc and doesn’t compile

  • 0

I have code, that compiles and runs as expected in gcc and doesn’t compile in MSVC 2012 RC, i can’t explain why, so it’s bug in MSVC, or my code is incorrect?

#include <boost/mpl/vector.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/size.hpp>
#include <boost/utility/enable_if.hpp>
#include <vector>
#include <iostream>

namespace mpl = boost::mpl;

template<typename T,
typename = void>
struct Some
{
   typedef std::vector<T> type;
};

template<typename T>
struct Some<T, typename boost::enable_if_c<mpl::is_sequence<T>::type::value>::type> :
    public Some<typename mpl::front<T>::type>::type
{
};


int main()
{
   typedef mpl::vector<int, double> vect_t;
   typedef Some<vect_t> vector;
   vector vect;
   vect.push_back(1);
   std::cout << "int: " << vect.at(0) << std::endl;
}

http://liveworkspace.org/code/45d78872a2c7f30192277a81c655b471

MSVC says, that push_back and at are not members of Some<vect_t>.

EDIT.

It looks like bug in MSVC 2012 since

#include <boost/mpl/vector.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/mpl/size.hpp>
#include <boost/utility/enable_if.hpp>
#include <vector>
#include <iostream>

namespace mpl = boost::mpl;

template<typename T, typename = void>
struct Some
{
    typedef std::vector<T> type;
};

template<typename T>
struct Some<T, typename boost::enable_if_c<mpl::is_sequence<T>::type::value>::type> :
    public std::vector<int>
{
};


int main()
{
   typedef mpl::vector<int, double> vect_t;
   typedef Some<vect_t>::type vector;
   vector vect;
   vect.push_back(1);
   std::cout << "int: " << vect.at(0) << std::endl;
}

gives errors, that i can’t push_back int into std::vector<boost::mpl::vector<int, double> >, so it choose general-case, not specialization…

EDIT.

Strange… But this works as expected

template<typename T>
struct Some<T, typename std::enable_if<boost::mpl::is_sequence<T>::value>::type> :
    public std::vector<int>
{
};

So, i can’t explain why, but MSVC 2012 cannot works with nested expressions in enable_if (or possibly in template parameters).

template<typename T>
struct is_int : public std::integral_constant<bool, false>
{
};

template<>
struct is_int<int> : public std::integral_constant<bool , true>
{
};

template<typename T, typename = void>
struct Some
{
    typedef void type;
};

template<typename T>
struct Some<T, typename std::enable_if<is_int<T>::type::value>::type>
{
    static_assert(is_int<int>::type::value, "asserted");
    typedef T type;
};

int main()
{
    static_assert(is_int<T>::type::value, "ass");
    Some<int>::type t = 0;
}
  • 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-06-10T09:38:40+00:00Added an answer on June 10, 2026 at 9:38 am

    I compile and run your code in MSVC 2010 successfully, so probably this is a bug in RC version of MSVC 2012. so event try it in MSVC 2012 final or wait for MSVC 2012 Express.

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

Sidebar

Related Questions

I have some code that compiles and runs on MSVC++ but will not compile
Challenge: I have this code that fails to compile. Can you figure out what's
I have some code written in C++ that compiles and runs fine (with reasonable
I have the following code that compiles and works well: template<typename T> T GetGlobal(const
I have a game code (from ioquake3 project) that compiles part of gameplay binaries
I have code that I want to compile on all unix systems, but if
I have following code snippet that i use to compile class at the run
I have this source code from 2001 that I would like to compile. It
I have code that runs on different platforms that seems to get different results.
I have an Xcode 4.3.2 iOS 5.1 project that compiles and runs fine when

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.