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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:47+00:00 2026-06-09T12:34:47+00:00

i seem to have some problem in creating a structure defined as the topic.

  • 0

i seem to have some problem in creating a structure defined as the topic.

My objective is to create a sort of event handler, (it doesn’t matter if it’s good or bad programming,or if it is not multithread: for the moment is just for practice).

My idea is then to create a vector of pointers to functions, and place this vector in a map,where the key is a string.

i must be doing something conceptually wrong, because i get some strange errors:
My code is as following (errors are at the end):

.h file
//ptr to function
typedef int (*pt2Function)(void*);
typedef std::vector<pt2Function> fPtrVector;

class eventDispatcher
{

public:
    //stuff 
    void addListener(std::string,pt2Function);

protected:
    //stuff
     std::map<std::string,fPtrVector> _listeners;
};

and here is the cpp:

.cpp file

void eventDispatcher::addListener(std::string eventName ,pt2Function function)
{
  std::map<std::string,fPtrVector>::iterator it;

  it=this->_listeners.find(eventName);
  if(it != this->_listeners.end())
  {
//do something
  }
  else 
  {
    std::vector<pt2Function> tmp;
    tmp.insert(function);  // here occurs error 1

    this->_listeners.insert(eventName,tmp);  // here occurs error 2
    std::cout<<"cnt: "<< this->_listeners.count(); 
  } 

}

The errors i get are:

1)  no matching function for call to 'std::vector <int (*)(void*), std::allocator<int (*)(void*)> >::insert(int (*&)(void*))'

2)  no matching function for call to 'std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int (*)(void*), std::allocator<int (*)(void*)> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int (*)(void*), std::allocator<int (*)(void*)> > > > >::insert(std::string&, std::vector<int (*)(void*), std::allocator<int (*)(void*)> >&)'
  • 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-09T12:34:48+00:00Added an answer on June 9, 2026 at 12:34 pm

    If you check a reference to insert you see that it takes two arguments, an iterator and the value. To just add a value use e.g push_back instead.

    For the map, you can use _listeners[eventName] = tmp; instead.

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

Sidebar

Related Questions

I seem to have a problem passing some strings on from one form to
i have some problems with a Query seem IN dosen't work with Group_concat, that
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
I have some colors that seem to come from a Delphi TColor variable (e.g
I have some troubles while writing logs from log4net to the file. I seem
I have been looking for some time for this and I can't seem to
I have a problem here, which I've not come across before and can't seem
I have 2 cases which seem like the same problem to me, even though
I am creating a game. I have some UI with text. Recently we wanted
I have a head aching problem that I can't seem to find an easy

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.