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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:00:09+00:00 2026-05-28T04:00:09+00:00

typedef struct { pthread_t threadId; int acceptSocketD; char *message; } threadData; map <unsigned int,

  • 0
typedef struct
{
    pthread_t threadId;
    int       acceptSocketD;
    char      *message;
} threadData;

map <unsigned int, threadData> serverPortNumberThreadId;
map <unsigned int, threadData> :: iterator serverPortNumberThreadIdIter;

usage:

threadData obj; 
obj.threadId      = 0;
obj.acceptSocketD = 0;
obj.message       = "Excuse Me, please!";

serverPortNumberThreadId.insert (3490, obj);

error:

error: no matching function for call to ‘std::map<unsigned int, threadData>::insert(int, threadData&)’
/usr/include/c++/4.5/bits/stl_map.h:500:7: note: candidates are: std::pair<typename std::map<_Key, _Tp, _Compare, _Alloc>::_Rep_type::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const std::map<_Key, _Tp, _Compare, _Alloc>::value_type&) [with _Key = unsigned int, _Tp = threadData, _Compare = std::less<unsigned int>, _Alloc = std::allocator<std::pair<const unsigned int, threadData> >, typename std::map<_Key, _Tp, _Compare, _Alloc>::_Rep_type::iterator = std::_Rb_tree_iterator<std::pair<const unsigned int, threadData> >, std::map<_Key, _Tp, _Compare, _Alloc>::value_type = std::pair<const unsigned int, threadData>]
/usr/include/c++/4.5/bits/stl_map.h:540:7: note:                 std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::iterator, const std::map<_Key, _Tp, _Compare, _Alloc>::value_type&) [with _Key = unsigned int, _Tp = threadData, _Compare = std::less<unsigned int>, _Alloc = std::allocator<std::pair<const unsigned int, threadData> >, std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const unsigned int, threadData> >, std::map<_Key, _Tp, _Compare, _Alloc>::value_type = std::pair<const unsigned int, threadData>]
tcpClient.cpp: In function ‘int main(int, char**)’
  • 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-28T04:00:10+00:00Added an answer on May 28, 2026 at 4:00 am

    You need a pair for the insert function, because in common with other containers insert takes the value_type, which in the case of map is a pair — each entry has a key and a mapped value. The value_type represents one entry in the container and hence includes both.

    You could write serverPortNumberThreadId[3490] = obj; instead, if you prefer the look of it. Behavior is sometimes different (insert does nothing if the key already exists, whereas this code overwrites it, but unless you’re relying on that behavior of insert already this makes no difference to you). Performance might be slightly different in terms of the number of threadData objects created/copied/assigned.

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

Sidebar

Related Questions

I have these structs: typedef struct _Frag{ struct _Frag *next; char *seq; int x1;
typedef struct child_list {int count; char vo[100]; child_list*next;} child_list; typedef struct parent_list { char
typedef struct child {int count; char word[100]; inner_list*next;} child; typedef struct parent { char
typedef struct BaseMessage { int u32DeviceID : 32; int u32CoreID : 32; unsigned int
typedef struct Value{ int id; char type; char a; } Value; void fooV(Value v){
typedef struct unit_class_struct { char *name; char *last_name; } person; int setName(person *array) {
typedef struct Model { int recordId; char *name; }Model; typedef struct ModelArray { //keeps
typedef struct { unsigned char a, unsigned char b, unsigned char c }type_a; typedef
Given: typedef struct { char val[SOME_FIXED_SIZE]; } AString; typedef struct { unsigned char val[SOME_FIXED_SIZE];
typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void

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.