Articles & Books

When noexcept?--Edouard of quasardb

A good question with a good answer.

When noexcept?

by Edouard of quasardb

From the article:

In a previous post, we had a look at the new constexpr keyword that has been introduced in C++ 11. Today we'll study another new fancy specifier: noexcept...

Simplifying templates and #ifdefs with if constexpr--Simon Brand

The new if constexpr will change a good part of our code for the better!

Simplifying templates and #ifdefs with if constexpr

by Simon Brand

From the article:

if constexpr is a C++17 feature which allows conditionally compiling code based on template parameters in a clear and minimal fashion. It is essentially an if statement where the branch is chosen at compile-time, and any not-taken branches are discarded without being instantiated...

Capturing perfectly-forwarded objects in lambdas -- Vittorio Romeo

Does [x = std::forward<decltype(x)>] behave like you expect?

capturing perfectly-forwarded objects in lambdas

by Vittorio Romeo

From the article:

Perfect forwarding and forwarding references allow developers to write generic template functions that retain the lvalueness/rvalueness of passed arguments [...] Let's try to use auto&&, std::forward and C++14's generalized lambda capture syntax to implement our desired semantics. [...] What we really want to do is:

  • Capture by copy if a is an rvalue reference.
  • Capture by reference if a is an lvalue reference.

[...]

Technical Debt - More Captureless Lambda Fun -- Adi Shavit

More interesting facts about captureless lambdas.

Technical Debt

by Adi Shavit

From the article:

The series on captureless lambdas generated some interesting comments.  
The articles discusses converting captureless lambdas into function pointers without explicitly specifying the cast-to type, calling conventions and standard conformance and a special callbackizing function for capturing lambdas.

C++ 17 Transformation...--phantom

The transformation is only a beginning towards catching up from C++98, but it does show why modern C++ features improve your code.

C++ 17 Transformation...

by phantom

From the article:

I'm basically really bad at working on my own projects, but with the recent release of Visual Studio 2017 RC and its improved C++17 support I figured it was time to crack on again...

To that end I've spent a bit of time today updating my own basic windowing library to use C++17 features. Some of the things have been simple transforms such as converting 'typedef' to 'using', others have been more OCD satisfying...

Basic dependent typing -- Krzysztof Ostrowski

Using fundamental types to do "simple things simple" fits very well in the most of cases.

Basic dependent typing

by Krzysztof Ostrowski

From the article:

If we assume that our application uses only a subset of values carried by given fundamental type, we are likely to get warning from the compiler. We shall take that warning seriously. How to inform type system about our assumptions? Example solutions follow.

C++ User Group Meetings in December

The monthly list of upcoming C++ User Group meetings:

C++ User Group meetings in December

by Jens Weller

From the article:

In total its already 30 groups which are meeting, also there are 10 new groups since the last posting:

Minsk, London, Melbourne, Karlsruhe, Ulm (Qt), San Diego, Belgrade, Luxembourg, Dallas FW, Plano.

The One-Definition Rule--Andrzej KrzemieĊ„ski

Something we should be aware of:

The One-Definition Rule

by Andrzej Krzemieński

From the article:

We have been hit by the same bug twice already this year. It ends in a crash, and it took developers days to find it (in each case), even though it is reproducible on each run of unit tests. The code, after significant simplifications, looks like this:

namespace tests
{
  struct Fixture
  {
    std::vector<int> v1;
    std::vector<int> v2;

    static Fixture create();
  };

  TEST_CASE(test1)
  {
    auto fixture = Fixture::create();
    std::cout << "running test1";
  }
}

Why you should use Boost.MultiIndex (Part II)--David Gross

The series continue:

Why you should use Boost.MultiIndex (Part II)

by David Gross

From the article:

A few weeks ago, I posted the first part of this article, where I explained the advantages of Boost.MultiIndex over the standard containers when you need to have multiple views on a set of data.

In this second part, I would like to talk about the benefits you can get from using Boost.MultiIndex as a single-index hash table, as a replacement of std::unordered_map.

One interesting and powerful aspect of Boost.MultiIndex is that it allows you to add an index of type T, where T is different from the stored type. And it is more frequent and useful that you could think.

Compose and curry as folds--Nick Athanasiou

With the next version of C++.

Compose and curry as folds

by Nick Athanasiou

From the article:

In a previous post we introduced C++17 fold expressions and described a way to extend them for arbitrary callables. Implementation details don’t matter for what we’re elaborating on here but it should be clear that (given the tools we developed) the following is possible:

(Op<F>(args) + ...)
(... + Op<F>(args))