Have you seen my recent blog post with the list of C++17 features? Probably this is not the best measurement, but it got only ~30% of the average read (while other articles might get like 70, or even 90%). I am not complaining, the list is crazy and contains probably too many details of the new standard.
C++ is a surprising language. Sometimes simple things are not that simple in practice. Last time I argued that in function bodies const should be used most of the time. But two cases were missed: when moving and when returning a value.
Does const influence move and RVO?
Intro Just to recall, we’re talking here about using const for variables inside function bodies.
This year we’ll get a new version of C++: C++17!
In this mega long article I’ve built a list of all features of the new standard.
Have a look and see what we get!
Intro Language Features New auto rules for direct-list-initialization static_assert with no message typename in a template template parameter Removing trigraphs Nested namespace definition Attributes for namespaces and enumerators u8 character literals Allow constant evaluation for all non-type template arguments Fold Expressions Unary fold expressions and empty parameter packs Remove Deprecated Use of the register Keyword Remove Deprecated operator++(bool) Removing Deprecated Exception Specifications from C++17 Make exception specifications part of the type system Aggregate initialization of classes with base classes Lambda capture of *this Using attribute namespaces without repetition Dynamic memory allocation for over-aligned data __has_include in preprocessor conditionals Template argument deduction for class templates Non-type template parameters with auto type Guaranteed copy elision New specification for inheriting constructors (DR1941 et al) Direct-list-initialization of enumerations Stricter expression evaluation order constexpr lambda expressions Different begin and end types in range-based for [[fallthrough]] attribute [[nodiscard]] attribute [[maybe_unused]] attribute Ignore unknown attributes Pack expansions in using-declarations Structured Binding Declarations Hexadecimal floating-point literals init-statements for if and switch Inline variables DR: Matching of template template-arguments excludes compatible templates std::uncaught_exceptions() constexpr if-statements SFINAE Tag dispatching if constexpr Library Features Merged: The Library Fundamentals 1 TS (most parts) Removal of some deprecated types and functions, including std::auto_ptr, std::random_shuffle, and old function adaptors Merged: The Parallelism TS, a.
Another year and another C++ Status! It’s hard to believe, but it’s my fifth time I am writing this summary. And, as usually, C++ language is very alive. The biggest news for the year?
Of course, it must be: the final draft for C++17!.
What else have happened? See my full report below.
I need to confess that for the last few years I’ve been a bit obsessed with the idea of making all variables const. Whenever I declare a variable in a function body, I try to think if I can make it constant. Let me explain why I think you should be doing the same.
Since 2011, when C++11 arrived, we all should be changing our coding style into modern C++ and at the same time keep good old tips. There are also general rules for programming and bug-free coding. Here’s a list of guidelines and other resources that might help you.
Core C++ Guidelines Main site: C++ Core Guidelines
The original code from my previous post about “nice factory” did not work properly and I though there is no chance to fix it.
It appears, I was totally wrong! I got a really valuable feedback (even with source code) and now I can present this improved version.
All credits should go to Matthew Vogt, who send me his version of the code and discussed the proposed solution.
As it appears, my last post about SFINAE wasn’t that bad! I got a valuable comments and suggestions from many people. This post gathers that feedback.
Comments from @reddit/cpp
Using modern approach In one comment, STL (Stephan T. Lavavej) mentioned that the solution I presented in the article was from old Cpp style.
This time I’d like to tackle a bit more complex problem: SFINAE. I’m not using this paradigm on a daily basis, but I’ve stumbled across it several times and I thought it might be worth trying to understand this topic.
What is SFINAE? Where can you use it? Do you need this on a daily basis?
After I finished my last post about a performance timer, I got a comment suggesting other libraries - much more powerful than my simple solution. Let’s see what can be found in the area of benchmarking libraries.
Intro The timer I’ve introduced recently is easy to use, but also returns just the basic information: elapsed time for an execution of some code… what if we need more advanced data and more structured approach of doing benchmarks in the system?
When you’re doing a code profiling session it’s great to have advanced and easy to use tools. But what if we want to do some simple test/benchmark? Maybe a custom code would do the job?
Let’s have a look at simple performance timer for C++ apps.
Intro A task might sound simple: detect what part of the code in the ABC module takes most of the time to execute.
Maybe I’ll be boring with this note, but again I need to write that this was another good year for C++!
Here’s a bunch of facts:
Visual Studio 2015 was released with great support for C++14⁄17 and even more experimental features. Long-awaited GCC 5.0 was released at the beginning of the year.