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 9277757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:11:18+00:00 2026-06-18T17:11:18+00:00

When moving from VC10 to VC11, the following code fails to compile. #include <algorithm>

  • 0

When moving from VC10 to VC11, the following code fails to compile.

#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
using namespace std::placeholders;

typedef std::function<void(int)> CB;


int main()
{
    vector<CB> m_CBs;
    int m_LongPressGesture;

  for_each(m_CBs.begin(), m_CBs.end(), bind(&CB::operator(), _1, m_LongPressGesture));
    return 0;
}

The error output is illegal indirection.
Here’s the complete output.

1>------ Build started: Project: CompileError, Configuration: Debug Win32 ------
1>Build started 2/12/2013 4:32:56 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\CompileError.unsuccessfulbuild".
1>ClCompile:
1>  main.cpp
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\functional(1269): error C2100: illegal indirection
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\functional(1152) : see reference to function template instantiation '_Rx std::_Pmf_wrap<_Pmf_t,_Rx,_Farg0,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>::operator ()<std::function<_Fty>>(_Wrapper &,_V0_t) const' being compiled
1>          with
1>          [
1>              _Rx=void,
1>              _Pmf_t=void (__thiscall std::_Func_class<void,int>::* )(int) const,
1>              _Farg0=std::_Func_class<void,int>,
1>              _V0_t=int,
1>              _V1_t=std::_Nil,
1>              _V2_t=std::_Nil,
1>              _V3_t=std::_Nil,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _Fty=void (int),
1>              _Wrapper=std::function<void (int)>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\functional(1152) : see reference to function template instantiation '_Rx std::_Pmf_wrap<_Pmf_t,_Rx,_Farg0,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>::operator ()<std::function<_Fty>>(_Wrapper &,_V0_t) const' being compiled
1>          with
1>          [
1>              _Rx=void,
1>              _Pmf_t=void (__thiscall std::_Func_class<void,int>::* )(int) const,
1>              _Farg0=std::_Func_class<void,int>,
1>              _V0_t=int,
1>              _V1_t=std::_Nil,
1>              _V2_t=std::_Nil,
1>              _V3_t=std::_Nil,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _Fty=void (int),
1>              _Wrapper=std::function<void (int)>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(24) : see reference to function template instantiation 'void std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>::operator ()<std::function<_Fty>&>(std::function<_Fty>)' being compiled
1>          with
1>          [
1>              _Forced=true,
1>              _Ret=void,
1>              _Fun=std::_Pmf_wrap<void (__thiscall std::_Func_class<void,int>::* )(int) const,void,std::_Func_class<void,int>,int,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,
1>              _V0_t=std::_Ph<1> &,
1>              _V1_t=int &,
1>              _V2_t=std::_Nil,
1>              _V3_t=std::_Nil,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _Fty=void (int)
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(24) : see reference to function template instantiation 'void std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>::operator ()<std::function<_Fty>&>(std::function<_Fty>)' being compiled
1>          with
1>          [
1>              _Forced=true,
1>              _Ret=void,
1>              _Fun=std::_Pmf_wrap<void (__thiscall std::_Func_class<void,int>::* )(int) const,void,std::_Func_class<void,int>,int,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,
1>              _V0_t=std::_Ph<1> &,
1>              _V1_t=int &,
1>              _V2_t=std::_Nil,
1>              _V3_t=std::_Nil,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _Fty=void (int)
1>          ]
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm(33) : see reference to function template instantiation 'void std::_For_each<std::function<_Fty>*,_Fn1>(_InIt,_InIt,_Fn1 &)' being compiled
1>          with
1>          [
1>              _Fty=void (int),
1>              _Fn1=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall std::_Func_class<void,int>::* )(int) const,void,std::_Func_class<void,int>,int,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,std::_Ph<1> &,int &,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,
1>              _InIt=std::function<void (int)> *
1>          ]
1>          c:\users\jedwards\documents\visual studio 2012\projects\compileerror\compileerror\main.cpp(16) : see reference to function template instantiation '_Fn1 std::for_each<std::_Vector_iterator<_Myvec>,std::_Bind<_Forced,_Ret,_Fun,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,<unnamed-symbol>>>(_InIt,_InIt,_Fn1)' being compiled
1>          with
1>          [
1>              _Fn1=std::_Bind<true,void,std::_Pmf_wrap<void (__thiscall std::_Func_class<void,int>::* )(int) const,void,std::_Func_class<void,int>,int,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,std::_Ph<1> &,int &,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,
1>              _Myvec=std::_Vector_val<std::_Simple_types<std::function<void (int)>>>,
1>              _Forced=true,
1>              _Ret=void,
1>              _Fun=std::_Pmf_wrap<void (__thiscall std::_Func_class<void,int>::* )(int) const,void,std::_Func_class<void,int>,int,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil,std::_Nil>,
1>              _V0_t=std::_Ph<1> &,
1>              _V1_t=int &,
1>              _V2_t=std::_Nil,
1>              _V3_t=std::_Nil,
1>              _V4_t=std::_Nil,
1>              _V5_t=std::_Nil,
1>              <unnamed-symbol>=std::_Nil,
1>              _InIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<std::function<void (int)>>>>
1>          ]
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.68
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The only thing I can come up with is bind is expecting a pointer. I tried ref() but made no difference.

Thanks,
Jim

  • 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-18T17:11:19+00:00Added an answer on June 18, 2026 at 5:11 pm

    Since VC apparently has a bug (thanks Stephan!), you could write the loop as:

    for ( auto &cb : m_CBs ) cb ( m_LongPressGesture );
    

    or:

    for_each ( m_CBs.begin(), m_CBs.end(), 
                 [m_LongPressGesture] ( const CB &cb ) { cb ( m_LongPressGesture ); } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are moving from WebForms to MVC and and using a lot of jQuery.
I'm moving from C to Java now and I was following some tutorials regarding
Moving from the Specs2 to Scalatest I tried using the WordSpec, but with no
I'm currently moving from symfony 1.4 using SVN to Symfony2 using Git. I am
I am currently moving from C to Objective-C and, to me, this code seems
I'm moving from windows programming (By windows programming I mean using Windows API )
Moving from jQuery 1.4.4 to jquery 1.6.4 started breaking my code related to radiobuttonlist.
I'm moving from xml mapping to a code based mapping. There is a problem
I am moving from PHP/MySQL to Google App Engine and using JDO as interface
I am currently considering moving from a svn/bugzilla system using scmbug to integrate the

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.