Tag Archives: c++11

Eric Niebler: out parameters, move semantics, and stateful algorithms

Eric Niebler: out parameters, move semantics, and stateful algorithms This post from Eric, inspired by a prompt from Andrei Alexcandrescu, examines the interface of std::getline appraising its usability and performance. Eric looks at a few different designs, in particular those … Continue reading

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Boost compile error “no class template named ‘result’”

I’ve just come across a compiler error resulting from using boost::result_of with a C++11 lambda. I wasn’t actually using boost::result_of directly, but provided a lambda as the transforming functor for a boost::transform_iterator, which uses it behind the scenes. Here’s a … Continue reading

Posted in Uncategorized | Tagged , , , | 1 Comment

Adventures in lock-free programming

I’ve been intrigued by the idea of lock-free programming since I discovered that C++0x (as it was then) was to gain library facilities for standardised, portable lock-free programming. The new <atomic> header enables us to perform atomic reads and writes … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Eric Niebler: stupid name lookup

Eric Niebler: stupid name lookup Eric Niebler shows a name lookup failure caused by a recursive template function inferring its return type via decltype. Stupid problem with a rather nasty hacky workaround, but also a likely change in C++14 that … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Using the standard allocator for a different type [and get free functionality for your custom allocator]

Someone on comp.lang.c++.moderated recently asked “if I have a different allocator, can I use that allocator to allocate memory with vector or string…?”. Since there is not only the mechanism supported by C++98/03, but also a more general – and … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Generalised type-deduction for class template instance construction

I’ll wager that most C++ developers with experience of templates have at some point discovered the limitation that a class template’s parameters cannot be deduced in construction. Since type deduction can be performed in invocation of a function template however, I … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Efficient argument passing in c++11 [via A Sense of Design]

Boris Kolpackov has written a series of 3 articles on the minefield of efficient argument passing in C++11. In part 1 he discusses the addition to C++11 – rvalue references – that improves argument-passing efficiency in some cases, but that … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

Virtual move constructor

Virtual constructor: recap Most experienced C++ developers should be familiar with the virtual constructor idiom, which allows us to duplicate a polymorphic object where we do not know its exact type, only the base. It is usually called clone and can … Continue reading

Posted in Uncategorized | Tagged , | 8 Comments

Compile-time binary literals [via pseudorandom noise]

Compile-time binary literals [via pseudorandom noise]

This is a great post that shows off the new user-defined literals feature in C++11, using it to implement binary number literals such as 1011101010111110_binary. Paul also shows off some great template metaprogramming to achieve this end including template specialization, variadic templates (with template parameter packs and template recursion), and the sizeof… operator, which I’d not previously come across.

Quite a collection of features to discuss in one post, but done clearly and cohesively.

Continue reading

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Herb Sutter to revisit Guru of the Week for C++11

I’ve just read on Herb’s site that he will be revisiting his superbGuru of the Week column, revising and adding articles to cover the changes brought by the new C++ standard, C++11. For those of you who haven’t seen it … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment