If you need it more than once in a single function consider: auto &mymap = *mptr; mymap[a] = x; mymap[b] = y; for even less uglyness.
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I guess it heavily depends on who reads the code. I as c++ detester would favor 3 because it is most clear but I assume a) is readable enough to be fine for those whose souls were eaten by the stroustrup.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
This Tweet is unavailable.
-
Oh yeah. That's better.
End of conversation
-
-
-
mptr->insert(std::pair(X,Y)); // C++17 If you use mptr more than once, consider auto &m = *mptr; // use m thereafter; so much nicer!
-
Thanks. I think https://twitter.com/Alnurn/status/1025713301337063424 … is better, and it only requires C++11 afaict.
This Tweet is unavailable. - Show replies
New conversation -
-
-
the first. It's almost pythonic.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
This isn't just a syntactic choice. A & B both default-construct and assign; C can in-place construct, depending on the type of X & Y.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.