Is the following code OK?

```
class A
{
  public:
    A();
    void foo();
};

map<int,A> m;
m[0].foo();

```

Or do I have to do the following:

```
map<int,A> m;
m[0] = A();
m[0].foo();

```

---

And also, can I do this:

```
map<int,A> m;
A a = m[5];

```

And how about access by reference:

```
void foo(A & a);
map<int,A> m;
foo(m[5]);

```