I've started using C++ recently and I've felt a strong urge to

```
#define print(msg) std::cout << msg << std::endl

```

Will this perform correctly in all situations? This is the only formulation I'm aware of that will work when there's a `<<` in msg (e.g. `"foo" << myInt`). Neither

```
#define print(msg) std::cout << (msg) << std::endl // note: parens

```

nor the suggested answer

```
template<typename T>
void print(T const& msg) {
    std::cout << msg << std::endl;
}

```

work in this case. I also don't care about the efficiency of flushing the output with `endl` vs just using `\n`.