How to determine the exact memory size of a map container?

Hello,

I have a question on how to determine the size of a STL map container for TCP transmission.

I have a class defined and one of the data elements within this class structure is a STL map container. Since TCP transmission requires the exact size for this buffer to be able to transmit correctly, my question is how to determine exactly size of the class object so I can send this object correct over the TCP socket?

For example, following is my definition:

typedef enum
{
Mary = 1,
Joe = 2,
Ken = 3,
May = 4
} name_t

Structure info_t
{
int bankId;
std:map<name_t, int> balance;
}

info_t myInfo; <======= This is to be transmitted over the TCP socket.


Thanks in advance for any answer.
Just serialize the map to a stream and check how many bytes were written.
You can then write the header and append the data to form a full message.
Topic archived. No new replies allowed.