简体   繁体   中英

unsigned char array as key in a map (STL - C++)

There are some posts related to this, but I need to clarify something. I have a structure in my program, and one of its fields is a fixed-size array (16). This is a reduced example of the mentioned structure:

my_struct{
     unsigned char my_field[16];
     ....
     // some more fields here
};

I want to use this field as a key for a map, and here is my question. - Is there a way to use a map like

map<unsigned char[16], some_defined_structure>

? Otherwise, which would be the best way to somehow copy this char array to fit an array or vector structure to insert in the map afterwards?

unsigned char[16] is not a suitable type for key map. it does not meet the requirements But std::array<unsigned char,16> does.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM