C++ Team Blog
The latest in C++, Visual Studio, VS Code, and vcpkg from the MSFT C++ team
Latest posts
The Visual C++ Weekly Vol. 1 Issue 8 (Feb 19, 2011)
Read in this issue:
MFC Application Instance Control
An interesting question, asked days ago in one of our C++ forums, was the following: A possible approach, based in mutex (mutual exclusion) objects, was posted a few hours later. In the proposed schema you declare a mutex object inside the MFC application class (i.e. the class header): When you define the MFC application InitInstance() method, you attempt to create the mutex -whose creation will succeed the first time, fail afterward.- About the else, the solution proponent (Bordon) said the following The "SendMessage" is only needed if you want that the running application...
The Visual C++ Weekly Vol. 1 Issue 7 (Feb 12, 2011)
Read in this issue:
shared_ptr – Advanced STL, Part 1
Part 1 of my video lecture series exploring the Standard Template Library's implementation is now available. In this part, I explain how some of shared_ptr's magic works, including type erasure and make_shared<T>()'s optimizations that save both space and time. This advanced series assumes that you're familiar with C++ and the STL's interface, but not the STL's implementation. If you haven't used the STL extensively yet, I recommend watching my introductory series. For reference, here are all of the links: [STL Introduction]Part 1 (sequence containers)Part 2 (associative containe...
Go Ask printf() To Behave Predictably
This is one of those problems whose solution is very evident… or bitterly hard to guess depending on how much you were influenced by what you were told about it.I’ll paste here the case You will rapidly solve it… or not! It will actually depend on what it impressed you the most about the symptoms.
C++ Renaissance: a Channel 9 Interview
If you don’t know Charles Torre, I’ll introduce him here: Charles is a BIG fan of C++ and he works for Channel 9 (in that order). Charles is the one to blame about the acclaimed series that Stephan put together about STL (beside Stephan himself). And Charles is encouraged to do more and more and more. So to put a beginning in an expectable increase in C++ material to be seen in Channel 9, he interviewed two Visual C++ top executives -Technical Fellow Mohsen Agsen and Director PM Craig Symonds- about the current perceived trends regarding C++ in the developer industry, that Mohsen synthesized in o...
The Visual C++ Weekly Vol. 1 Issue 6 (Feb 5, 2011)
For this week roundup, we start with a game that C++ MVP Marius Bancila code, inspired on his favorite phone game. You can download the code and study or just play it right away. We tell you how to validate, in Visual Studio 2010, C/C++ code against architecture layer diagrams in order to avoid cross-layer dependencies. C++ MVP PJ Naughter offers an MFC GUI control class which implements display of OpenStreetMap tiles. Cameron and Tracey Hughes discuss on threads and contention. C++ MVP Giovanni Dicanio explains a technique to convert STL strings of different Unicode character width. In our entrepreneur column, w...
Concurrent Containers
A recurrent question (well, one of the many) is about STL containers and whether they are thread safe.Taking Stephan’s words here, the reality is that they aren’t, not as a bug but as a feature: having every member function of every STL container acquiring an internal lock would annihilate performance. As a general purpose, highly reusable library, it wouldn’t actually provide correctness either: the correct level to place locks is determined by what the program is doing. In that sense, individual member functions don’t tend to be such correct level. // This article tells more about Thread...
PDC 2010: Lambdas, Lambdas Everywhere
Why care about C++0x lambda functions? Syntactically, they are nothing but sugar for function objects. However, they are an essential and enabling sugar that will change the way we will write C++ code more often than most people realize. This talk from last PDC covers what lambda functions are and how to use them effectively, including how lambdas touch many wide-ranging kinds of code — from their convenience when writing concurrent and scalably parallel code, to how they stand to revolutionize STL usability and programming, to how they enable such small conveniences as local functions and local variable i...