C++14

A Tour of Rare C++ Features Part 6: Declaring Variables in If Statements, Function Style Casts and Digit Grouping

In the previous installment of this series we dealt with the function declaration from hell. This post will focus on the if/else that follows it in the example that guides us through this series. For your convenience, I have highlighted the only parts of the example that remain completely undiscussed as of now: /* This is valid C++ */ auto main() - decltype('O.o') try <%[O_O = 0b0]<% https://gha.st/a-tour-of-rare-cpp-features/ typedef struct o O; o*(*((&&o(o*o))<:'o':>))(o*o); if(O*O = decltype(0'0[o(0)](0))(0)) 1,000.

Comprehensive C++ Lambda Overview

This article is intended to be a comprehensive but still understandable and beginner-friendly overview over lambda functions in C++. Any section marked as “advanced” can be safely skipped, although they should be readable enough to understand for intermediate C++ developers as well. Please be aware that most of these features require at least C++11 support (g++ and clang++ activate it via the -std=c++11 argument) and generalized lambda captures even require C++14 support (g++ and clang++ activate it via the -std=c++14 argument).

A Tour of Rare C++ Features Part 4: Generalized Lambda Captures, Binary Literals and URLs

In the previous installment we discovered the ancient Digraphs and Trigraphs, as well as the more modern lambda expressions. We did however leave out what exactly the capture list that is used in the guiding example of this series means, which is the first topic of this post. Afterwards we will spend a tiny bit of time on how there can be an URL directly in the code. The guiding example of this series is still the same and should now start to make a small bit of sense if you have read the previous posts in this series:

A Tour of Rare C++ Features Part 3: Digraphs, Trigraphs and Lambda Functions

In the previous installment we explored function try blocks, catch-all exception handlers and the correct way to rethrow exceptions. This time, we are going to talk about ancient and fairly modern features: Digraphs have been around for so long that the reason for their existence might be surprising, while lambda functions are one of the big new features in C++11, which have been further refined with C++14. The example for this post is still the same one as in the previous ones and should now start to make a tiny bit of sense if you have read the previous posts in this series:

A Tour of Rare C++ Features Part 2: Function Try Blocks, Catch-All Exception Handlers and Rethrowing

In the previous installment of this series we explored the combined use of trailing return types, decltype and multicharacter literals that together explain why the following snippet actually contains a correct main function: /* This is valid C++ */ auto main() -> decltype('O.o') try <%[O_O = 0b0]<% https://gha.st/a-tour-of-rare-cpp-features/ typedef struct o O; o*(*((&&o(o*o))<:'o':>))(o*o); if(O*O = decltype(0'0[o(0)](0))(0)) 1,000.00; else return 0==O==0 ? throw O_O : O_O; %>();%> catch(...) { throw; } This time, we are going to explore how the body of this function can be correct.

A Tour of Rare C++ Features Part 1: Trailing Return Types, decltype and Multicharacter Literals

C++ is a treasure trove of entertaining, fascinating and just plain weird features. While most of them have sound reasons, rules like that “main may not be called by the program” feel rather arbitrary. Add to that, that there is a lot of rules and features, and some of them will fall through the cracks. As there are very real reasons not to use many of the features I am going to present, I have made a small example that demonstrates the result of what can happen if you enjoy this kind of activity too much: