Please consider the following code where I get an access violation inserting values into a std::map object. Not sure why. The code as you see it uses 

```
std::map<int, int>

```

however, I initially tried 

```
std::map<int, MSGTYPE>

```

with the same resulting access violation. (I know enums are INTs).

```
// a common include file has this
// common.h

enum MSGTYPE
{
  MSG_R1,
  MSG_A1,
  MSG_L1,
  MSG_S1,
  MSG_S2
};

typedef std::map<int, int> SYSMsgMap;

typedef struct _MYOBJ
{
  int x1;
  int x2;
  SYSMsgMap XFerMap;
}MYOBJ;

```

My use of these structures looks like so:

```
MYOBJ *cMYOBJ::AddNetwork(cvnet *net)
{
MYOBJ *ob;

  ob = new MYOBJ();

  // initialization code removed for this post/brevity

  BuildMsgMap(ob->XFerMap);

  // rest removed for this post/brevity
}

void cMYOBJ::BuildMsgMap(std::map<int, int> &mm)
{

  mm.clear();

  switch(NETTYPE)
  {
    case 1: 
      mm[ 1] = MSG_R1;  <-- Access violation here!
      mm[ 2] = MSG_A1;
      mm[ 4] = MSG_L1;
      mm[16] = MSG_S1;
      mm[32] = MSG_S2;
    break;

 // rest removed...
}

```