The Synchronizes-With Relation -- Jeff Preshing
Here is a nicely accessible description of synchronization in the C++ memory model:
The Synchronizes-With Relation
by Jeff Preshing
See also Jeff's other recent related posts:
October 25, Pavia, Italy
November 6-8, Berlin, Germany
November 3-8, Kona, HI, USA
By Blog Staff | Aug 23, 2013 09:26 AM | Tags: intermediate concurrency
Here is a nicely accessible description of synchronization in the C++ memory model:
The Synchronizes-With Relation
by Jeff Preshing
See also Jeff's other recent related posts:
By matt | Aug 23, 2013 06:06 AM | Tags: polymorphism intermediate crtp cloning c++11
On CRTP with multi-level inheritance, cloning, and the constructor forwarding problem.
C++: Polymorphic cloning and the CRTP (Curiously Recurring Template Pattern)
by Katy Coe
From the article:
A common problem in C++ occurs when you have an object of an unknown derived type and want to make a copy of it. ...
The solution is to use the commonly-used polymorphic cloning pattern. In this pattern, we define a virtual function -- which we’ll call
clone()in this article -- which when called via an object pointer returns a new object of the correct derived type.
By Blog Staff | Aug 21, 2013 07:01 PM | Tags: basics
Today on Dr. Dobb's:
Moving Data and Address Arithmetic
by Andrew Koenig
From the article:
Programs that don't care about the addresses of their data rarely need to move those data. After all, we can view the whole point of moving an object as a way of changing the object's address without changing its contents...
By Cecilia | Aug 20, 2013 09:06 PM | Tags: None
[Ed.: We're pleased to report continued progress toward conformance by C++ compiler vendors. This post combines three features contributed by Cecilia, christineli, and Alice Ying]
The IBM XL C/C++ V11.1 now supports several new C++11 features.
With extern templates, you can provide an explicit instantiation declaration for a template specialization if an explicit instantiation definition of the template exists in other translation units or later in the same file. If one translation unit contains the explicit instantiation definition, other translation units can use the specialization without having the specialization instantiated multiple times.
With right angle brackets, you can avoid having to write an extra space in code like vector<list<int> >, and just write vector<list<int>> the way Stroustrup intended.
With scoped enumerations, you can avoid the following problems with the traditional enumerations:
Enjoy!
By Blog Staff | Aug 20, 2013 06:03 PM | Tags: intermediate
A slight change from C++98 to C++11, tightening up destructor semantics. Yes, it's still considered a best practice to never allow an exception to escape from a destructor -- in any language with destructor or
Dispose functionality -- and now we have an additional reason in C++11:
noexcept Destructors
by Andrzej Krzemieński
From the article:
The goal of this post is to show one — fairly small — backwards incompatibility in C++11. It shows how
noexceptexception specifications are implicitly generated for your destructors. In short, the following program used to run successfully in C++03 (under some definition of “success”): ...In this post I do not intend to argue whether it is a bad practice or not to throw from destructors, but focus on what happens when you do. But I really do not encourage you to throw from destructors...
By matt | Aug 19, 2013 07:05 AM | Tags: intermediate basics
The solution to the latest GotW problem is now available. In this Item, the focus is on analyzing and managing compile-time dependencies.
by Herb Sutter
From the article:
Managing dependencies well is an essential part of writing solid code. C++ supports two powerful methods of abstraction: object-oriented programming and generic programming. Both of these are fundamentally tools to help manage dependencies, and therefore manage complexity. It’s telling that all of the common OO/generic buzzwords—including encapsulation, polymorphism, and type independence—along with most design patterns, are really about describing ways to manage complexity within a software system by managing the code’s interdependencies.
When we talk about dependencies, we usually think of run-time dependencies like class interactions. In this Item, we will focus instead on how to analyze and manage compile-time dependencies. As a first step, try to identify (and root out) unnecessary headers.
Guideline: Never #include unnecessary header files.
Guideline: Prefer to #include <iosfwd> when a forward declaration of a stream will suffice.
Guideline: Never #include a header when a forward declaration will suffice.
By Meeting C++ | Aug 18, 2013 10:21 AM | Tags: standardization performance experimental concurrency
A look at resumable functions:
Resumable Functions: async and await
by Jens Weller
From the article:
While I did my series about the papers for Bristol, there was one paper, which I personally found a bit weird. This paper was about resumable functions, and at that time it was just another paper full of ideas for C++ to me. At C++Now suddenly, I got a better insight to what the use of resumable functions could be...
By Meeting C++ | Aug 17, 2013 08:54 AM | Tags: intermediate functional experimental
A nice series on functional programming in C++
Functional C++: Type Classes
by whanhee
From the article
Type classes are a feature of Haskell which is very similar to the upcoming Concepts. Both define interfaces to a data type, which can be defined separately from the data, in contrast to member functions...
By Meeting C++ | Aug 16, 2013 08:53 AM | Tags: performance intermediate efficiency
A nice comparison on converting a string to int:
C++ String to Int
by Ivan Neeson
From the article:
In this post I will compare the following methods for parsing a string into an integer in C++:
- Manually
atoi()strtol()sscanf()std::stoi(C++11 only)std::istringstream- Boost.LexicalCast
- Boost.LexicalCast with C locale
- Boost.Spirit.Qi
- Boost.Coerce
By Blog Staff | Aug 15, 2013 11:18 PM | Tags: intermediate basics advanced
Overload 116 is now available. It contains the following articles, and more:
When is the use of auto good, and when is it evil?
Alex Fabijanic and Richard Saunders continue to explore dynamic solutions in C++.
How hard can it be to make a file in C++ with international text literals in its name? Alf Steinbach shows us how to write a file called π.recipe.
How low can latency really get?
... and more!