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.
Monthly Archives: November 2012
Visual Studio 2012 fixes many C++11 bugs found in VS 2010
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++
std::initializer_list – an even better way to populate a vector
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
Variadic Templates – example that simplifies populating a vector
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
Continuous Delivery Podcast – Jez Humble and Martin Fowler
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
Herb Sutter Podcast – “Why C++?” on HanselMinutes
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++.
Rule of Zero
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++
The Fear and Wisdom of Convergence – Cloud, Big Data and Low Latency
Thought provoking piece about emerging new technologies being used for trading: Cloud, Big Data and Low Latency
Filed under Technology
Stephan Lavavej Video – VS2012 C++ November CTP
Introductory video on the Visual Studio 2012 C++ Compiler November CTP (download the CTP here):
A special episode in which Stephan takes a look at the latest C++11 features that were just added to the Visual C++ compiler:
Variadic templates
Raw string literals
Explicit conversion operators
Default template arguments for function templates
Delegating constructors
Uniform initialization