C++11 Tutorial: Explaining the Ever-Elusive Lvalues and Rvalues

Every C++ programmer is familiar with the terms lvalue and rvalue. It’s no surprise, since the C++ standard uses them “all over”, as do many textbooks. But what do they mean? Are they still relevant now that C++11 has five value categories? It's about time to clear up the … [Read more...]

A Glimpse into C++14: Combine Flexibility and Performance with Dynamic Arrays and Runtime-Sized Arrays

C99 introduced the notion of variable length arrays: stack allocated built-in arrays whose size is determined at runtime. C++ lacks a similar feature, to the discontent of many a programmer. However, two recent proposals for adding dynamic arrays and runtime-sized arrays to … [Read more...]

Use C++11 Inheritance Control Keywords to Prevent Inconsistencies in Class Hierarchies

For more than 30 years, C++ got along without inheritance control keywords. It wasn’t easy, to say the least. Disabling further derivation of a class was possible but tricky. To prevent users from overriding a virtual function in a derived class you had to lean over … [Read more...]

Closer to Perfection: Get to Know C++11 Scoped and Based Enum Types

C++ enum types pack a set of related constants in an intuitive and efficient user-defined type. Can you ask for more? With two new C++11 enhancements, namely scoped enums and based enums, the answer is “yes.” Find out all about the recent facelift that C++11 enums underwent … [Read more...]

Using constexpr to Improve Security, Performance and Encapsulation in C++

constexpr is a new C++11 keyword that rids you of the need to create macros and hardcoded literals. It also guarantees, under certain conditions, that objects undergo static initialization. Danny Kalev shows how to embed constexpr in C++ applications to define constant … [Read more...]

C++11 Tutorial: Lambda Expressions — The Nuts and Bolts of Functional Programming

One highlight of C++11 is lambda expressions: function-like blocks of executable statements that you can insert where normally a function call would appear. Lambdas are more compact, efficient, and secure than function objects. Danny Kalev shows you how to read lambda … [Read more...]

C++11 Tutorial: Let Your Compiler Detect the Types of Your Objects Automatically

Imagine that your compiler could guess the type of the variables you declare as if by magic. In C++11, it’s possible — well, almost. The new auto and decltype facilities detect the type of an object automatically, thereby paving the way for cleaner and more intuitive … [Read more...]

C++11 Tutorial: New Constructor Features that Make Object Initialization Faster and Smoother

Constructors in C++11 still do what they’ve always done: initialize an object. However, two new features, namely delegating constructors and class member initializers, make constructors simpler, easier to maintain, and generally more efficient. Learn how to combine these new … [Read more...]

C++11 Tutorial: Introducing the Move Constructor and the Move Assignment Operator

Copy constructors sounds like a topic for an article from 1989. And yet, the changes in the new C++ standard affect the design of a class' special member functions fundamentally. Find out more about the impact of move semantics on objects' behavior and learn how to implement … [Read more...]

C11: A New C Standard Aiming at Safer Programming

Thirteen years after the ratification of the C99 standard, a new C standard is now available. Danny Kalev, a former member of the C++ standards committee, shares an overview of the goodies that C11 has to offer including multithreading support, safer standard libraries, and … [Read more...]