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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:04:32+00:00 2026-06-09T21:04:32+00:00

sockets map def: map<unsigned char[6],RawSocket> sockets_; set value to the sockets map: RawSocket tmp(ifcName,newSocketsIt->src_mac_);

  • 0

sockets map def:

map<unsigned char[6],RawSocket> sockets_;

set value to the sockets map:

RawSocket tmp(ifcName,newSocketsIt->src_mac_);
sockets_[newSocketsIt->src_mac_] = tmp;

RawSocket def:

class RawSocket{
public:
    RawSocket(string ifcName,const unsigned char dstMac[6]);
}

I dont want to have default constructor for RawSocket.
error is:

/usr/include/c++/4.6/bits/stl_map.h: In member function ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = unsigned char [6], _Tp = RawSocket, _Compare = std::less<unsigned char [6]>, _Alloc = std::allocator<std::pair<const unsigned char [6], RawSocket> >, std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = RawSocket, std::map<_Key, _Tp, _Compare, _Alloc>::key_type = unsigned char [6]]’:
../sockets_container.cpp:18:34:   instantiated from here
/usr/include/c++/4.6/bits/stl_map.h:453:11: error: no matching function for call to ‘RawSocket::RawSocket()’
/usr/include/c++/4.6/bits/stl_map.h:453:11: note: candidates are:
/root/workspace/networkutils/src/raw_socket.h:23:2: note: RawSocket::RawSocket(std::string, const unsigned char*)
/root/workspace/networkutils/src/raw_socket.h:23:2: note:   candidate expects 2 arguments, 0 provided
/root/workspace/networkutils/src/raw_socket.h:21:7: note: constexpr RawSocket::RawSocket(const RawSocket&)
/root/workspace/networkutils/src/raw_socket.h:21:7: note:   candidate expects 1 argument, 0 provided
/root/workspace/networkutils/src/raw_socket.h:21:7: note: constexpr RawSocket::RawSocket(RawSocket&&)
/root/workspace/networkutils/src/raw_socket.h:21:7: note:   candidate expects 1 argument, 0 provided

insert like this :

sockets_.insert(pair<unsigned char[6],RawSocket>(newSocketsIt->src_mac_,tmp));

will failed with this error:

/usr/include/c++/4.6/bits/stl_pair.h: In constructor ‘std::pair<_T1, _T2>::pair(const _T1&, _U2&&) [with _U2 = RawSocket&, <template-parameter-2-2> = void, _T1 = unsigned char [6], _T2 = RawSocket]’:
../sockets_container.cpp:19:78:   instantiated from here
/usr/include/c++/4.6/bits/stl_pair.h:126:45: error: array used as initializer
/usr/include/c++/4.6/bits/stl_pair.h: In constructor ‘std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U1 = unsigned char [6], _U2 = RawSocket, _T1 = const unsigned char [6], _T2 = RawSocket]’:
/usr/include/c++/4.6/bits/stl_tree.h:139:49:   instantiated from ‘std::_Rb_tree_node<_Val>::_Rb_tree_node(_Args&& ...) [with _Args = {std::pair<unsigned char [6], RawSocket>}, _Val = std::pair<const unsigned char [6], RawSocket>]’
/usr/include/c++/4.6/ext/new_allocator.h:114:4:   instantiated from ‘void __gnu_cxx::new_allocator<_Tp>::construct(__gnu_cxx::new_allocator<_Tp>::pointer, _Args&& ...) [with _Args = {std::pair<unsigned char [6], RawSocket>}, _Tp = std::_Rb_tree_node<std::pair<const unsigned char [6], RawSocket> >, __gnu_cxx::new_allocator<_Tp>::pointer = std::_Rb_tree_node<std::pair<const unsigned char [6], RawSocket> >*]’
/usr/include/c++/4.6/bits/stl_tree.h:405:8:   instantiated from ‘std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {std::pair<unsigned char [6], RawSocket>}, _Key = unsigned char [6], _Val = std::pair<const unsigned char [6], RawSocket>, _KeyOfValue = std::_Select1st<std::pair<const unsigned char [6], RawSocket> >, _Compare = std::less<unsigned char [6]>, _Alloc = std::allocator<std::pair<const unsigned char [6], RawSocket> >, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const unsigned char [6], RawSocket> >*]’
/usr/include/c++/4.6/bits/stl_tree.h:971:66:   instantiated from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, _Arg&&) [with _Arg = std::pair<unsigned char [6], RawSocket>, _Key = unsigned char [6], _Val = std::pair<const unsigned char [6], RawSocket>, _KeyOfValue = std::_Select1st<std::pair<const unsigned char [6], RawSocket> >, _Compare = std::less<unsigned char [6]>, _Alloc = std::allocator<std::pair<const unsigned char [6], RawSocket> >, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const unsigned char [6], RawSocket> >, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr = const std::_Rb_tree_node_base*]’
/usr/include/c++/4.6/bits/stl_tree.h:1285:64:   instantiated from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = std::pair<unsigned char [6], RawSocket>, _Key = unsigned char [6], _Val = std::pair<const unsigned char [6], RawSocket>, _KeyOfValue = std::_Select1st<std::pair<const unsigned char [6], RawSocket> >, _Compare = std::less<unsigned char [6]>, _Alloc = std::allocator<std::pair<const unsigned char [6], RawSocket> >]’
/usr/include/c++/4.6/bits/stl_map.h:526:64:   instantiated from ‘std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename _Alloc::rebind<std::map<_Key, _Tp, _Compare, _Alloc>::value_type>::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(_Pair&&) [with _Pair = std::pair<unsigned char [6], RawSocket>, <template-parameter-2-2> = void, _Key = unsigned char [6], _Tp = RawSocket, _Compare = std::less<unsigned char [6]>, _Alloc = std::allocator<std::pair<const unsigned char [6], RawSocket> >, typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename _Alloc::rebind<std::map<_Key, _Tp, _Compare, _Alloc>::value_type>::other>::iterator = std::_Rb_tree_iterator<std::pair<const unsigned char [6], RawSocket> >]’
../sockets_container.cpp:19:79:   instantiated from here
/usr/include/c++/4.6/bits/stl_pair.h:137:40: error: array used as initializer
  • 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-09T21:04:33+00:00Added an answer on June 9, 2026 at 9:04 pm
    sockets_[newSocketsIt->src_mac_] = tmp;
    

    map‘s operator[] is trying to default construct an element with that key, because it isn’t in the map yet. It would then assign tmp to it via operator=. You’ll either need to provide default constructor for RawSocket or use std::map::insert() instead;

    You’re getting an error with insert because unsigned[6] and src_mac_ are both array types and you can’t initialize an array with another array (this happens when you’re making std::pair). Consider switching to a container like std::array or std::vector or wrap the array in your own struct and use that as key.

    Quick workaround would be:

    struct Arr6 {
        unsigned char array[6];
    };
    
    std::map <Arr6, RawSocket> sockets_;
    

    Change the definiton of src_mac_ to be Arr6, too.

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

Sidebar

Related Questions

Using sockets, I am not sure how to set the timeout? thanks int sock,
i am using raw sockets to create my own socket. i need to set
I'm making an application where I need to map sockets to some object. I
I have my customize Map Class template <class TKey, class TVal> class CLSimpleMap{}; typedef
I have a question: Are std::map and std::set thread-safe? I use this collections on
Should sockets be set to non-blocking when used with select.select in Python? What difference
Sockets on Linux question I have a worker thread that is blocked on an
Ever since I discovered sockets, I've been using the nonblocking variants, since I didn't
In C we have Sockets and descriptors, it is possible to just take one
Can Silverlight 3 OPEN SOCKETS? If yes. What do I need MSDN if there

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.