Excellent tutorial on a selection of Modern C++ techniques by Michael Caisse.
Topics include:
Policy Based Design
SFINAE
Tag Dispatching
Traits
Curious Recurring Template Pattern
This is a two part video series:
and with slides.
Excellent tutorial on a selection of Modern C++ techniques by Michael Caisse.
Topics include:
Policy Based Design
SFINAE
Tag Dispatching
Traits
Curious Recurring Template Pattern
This is a two part video series:
and with slides.
Raymond Chen relates a story where the debugger obscures the very information that provoked the bug.
Be aware that the value in the crash dump is the value that existed in memory a split second after the crash occurred. During that split second, other things may have happened.
Filed under Programming
Really enjoyed reading the history of BBC News Online, which apparently started as a skunkworks project and succeeded largely because of the passion and technical brilliance of a small group of people.
Filed under Technology
Alex Korban (author of C++ Rocks) has compiled a list of C++ features that work better in VS 2012 than in VS 2010 thanks to 23 bug fixes.
Filed under C++
Visual Studio 2012 November CTP does provide us with support for initializer lists, even though standard library containers like vector<T> do not yet implement constructors that accept an initializer list. However, that doesn’t stop us writing code like this to make populating containers easy:
namespace musingstudio
{
template<typename Container>
Container initialize(
std::initializer_list<typename Container::value_type> items )
{
return Container( items.begin(), items.end() );
}
}
And call it like this:
auto evens = musingstudio::initialize<vector<int>>({2,4,6,8,10});
I like the way this reads “initialize vector of int( values )” – and it’s pretty efficient too, if your container supports move semantics (which the standard library containers do).
Filed under C++ Code
I was hoping that Visual Studio 2012 would allow us to initialise a std::vector; like this, especially with the November CTP:
std::vector<int> items = { 1, 2, 3, 4, 5 };
However, although the November CTP includes support for variadic templates and uniform initialisation, they haven’t yet decorated all standard templates with initializer lists as needed for the above. That tempted me to write a simple variadic template to avoid having to write code like this ever again:
std::vector<int> items; items.push_back(0); items.push_back(1); items.push_back(2);
By writing this:
namespace musingstudio
{
template<typename T, typename U, typename ...Args>
void push_back(std::vector<T>& items, U item, Args ...args)
{
items.push_back(item);
push_back( items, args... );
}
template<typename T, typename U>
void push_back(std::vector<T>& items, U item)
{
items.push_back(item);
}
}
We can then write this:
std::vector<int> items; musingstudio::push_back( items, 0,1,2,3,4,5 );
Obviously, this is less efficient than implementing a constructor that takes initializer lists, but it’s more fun than repeatedly typing push_back the C++98/03 way.
Filed under C++ Code
HanselMinutes on Continuous Delivery
Scott sits down with Jez Humble and Martin Fowler at the GOTO Conference in Aarhus, Denmark to talk about Continuous Delivery. How do your software systems have to change if you deploy weekly? Daily? How about 10 times a day?
Filed under Podcast, Programming
HanselMinutes interviews Herb Sutter on “Why C++?”
The world runs on C and C++. Did you know that? Herb Sutter sits down to convince Scott that he’s not only standing on the shoulders of giants but that those giants all write C++.
Interesting take on the need or otherwise to write move constructors by R. Martinho Fernandes (Flaming Dangerzone) :-
So, we have arrived at the Rule of Zero (which is actually a particular instance of the Single Responsibility Principle):
Classes that have custom destructors, copy/move constructors or copy/move assignment operators should deal exclusively with ownership. Other classes should not have custom destructors, copy/move constructors or copy/move assignment operators.
Filed under C++