As I understand it, the range-v3 library's view operations (requires C++17 currently, but to become an official part of the STL in C++20) provides chainable STL-like algorithms that are lazily evaluated. As an experiment, I created the following code to evaluate the first 4 perfect numbers:
Modifying a const constructed object after a const_cast is UB (I believe due to constant propagation). Is it still UB even when combined with std::launder (which AFAIK prevents some optimizations such as const propagation)?
Based on c++ operator doc, ',' is a left to right operator. It is meaning a, b, c, d meaning (((a, b), c),d) not (a, (b, (c, d))). This is important if a, b, c, d are statements.
Nicolai Josuttis' "The Nightmare of Initialization in C++" presentation at CppCon 2018 had, at one point, the following piece of code:
Consider the following piece of code (notice the comment):To compile this program, I am using the GNU C++ Compiler g++:
As I am beginning to take advantage of the C++17 structured bindings and if operator init statements for more elegant function result reporting and checking, I started doing the following, if accordance with C++ Core Guideline F21:
I'm compiling using g++ for C++ 17. I have the following:I don't understand why if I remove the double braces for the array it does not work anymore.
I just watched Stephan T. Lavavej talk at CppCon 2018 on "Class Template Argument Deduction", where at some point he incidentally says:
When given code of the following structureI've often seen library code use static_cast<Args&&> within the function for argument forwarding. Typically, the justification for this is that using a static_cast avoids an unnecessary template instantiation.
This has been asked before, but I'm curious to see if anything has changed in newer C++ standards. Any current or future standard is acceptable.