Tag Archives: templates

An implementation of generic lambdas (request for feedback) Faisal Vali has created an initial, alpha implementation (in Clang) of the current Generic (Polymorphic) Lambda Expressions proposal (N3418). This would see the addition of support for templated lambda expressions; the current … Continue reading

Link | Posted on by | Tagged , , , | Leave a comment

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

Link | Posted on by | 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

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

Link | Posted on by | Tagged , , , , , , | Leave a comment

Template parameter deduction from array dimensions

The template facility in C++ doesn’t only allow you to parameterise with types (such as the int in std::vector<int>), but also with values. Non-type template parameters can be of the following types[1]: Integral (or enum) value Pointer to object/function Reference … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment