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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:43:19+00:00 2026-05-23T14:43:19+00:00

Im working on a small graphics engine project that and I want to it

  • 0

Im working on a small graphics engine project that and I want to it to be crossed platform (someday). I been developing with latest version of MinGW and C++0x.
For event listeners I use lambda functions stored in a std::map that will be called when a certain event occurs. It works really smooth with MinGW but the other day when I tried it in Visual Studio (latest version) it failed.

I inspected the type of the lambdas and even if I define two lambdas to be excatly the same, they get different types (annonymous namespace:: and annonymous namespace::)).

For example i have this std::map to store scroll listeners

std::map<int,void (*)(int p)> scrollListenerFunctions;

And then I can add a listener by just do:

addScrollListener([](int p){/* Do something here */});

As I said, this works fine in MinGW but fails in Visual Studio, is there a way of doing it so it works in both and is it even possible to store lambdas in VS atm?

If you wnat/need to see more code you can find it here http://code.google.com/p/aotk/source/browse/ the lambda maps are located in window.h / window.cpp

  • 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-23T14:43:19+00:00Added an answer on May 23, 2026 at 2:43 pm

    instead of this:

    std::map<int,void (*)(int p)> scrollListenerFunctions;
    

    you must have this:

    std::map<int,std::function<void(int p)> > scrollListenerFunctions;
    

    The thing is that a lambda is not convertible to a function-pointer. You need a more generic callback wrapper, like std::function

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

Sidebar

Related Questions

I'm working on a small UML editor project, in Java, that I started a
Right now I'm developing a small canvas oriented 2D graphics engine for a game,
I'm working a small, personal Django project and I've added South (latest mercurial as
I've been quite used to working on small projects which I coded with 1,000
I'm working on a small templating engine, and I'm using DOMDocument to parse the
I'm working with a small FAT16 filesystem, and I want to generate CRC values
I'm working in a small company and weeks away from deploying a web-app that
I'm working on a small project to help me tag content on Flickr. I've
We're a small dev team working with some GLSL that may be too large
I am working on this small project where I'd like to generate the call

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.