The next big Thing - Andrei Alexandrescu - Meeting C++ 2018 Opening Keynote

Save to:
Instapaper Pocket Readability

Andrei Alexandrescus Opening Keynote from Meeting C++ 2018

The next big Thing

by Andrei Alexandrescu

 

Add a Comment

Comments are closed.

Comments (1)

0 0

Helmut Zeisel said on Jan 14, 2019 02:23 AM:

Does "if constexpr" really need a fix?

In slides 27 to 32 Andrei Alexandrescu says that "if constexpr" must not introduce a scope. He gives an example that "if constexpr" cannot be used to specify types depending on template paramters (because the specified types are not visible outside of the scope). This is treu, but there are other well known techniques that can be used to achieve these goal (For example, define some kind of type traits). Using this technique, hiscode changes to


template <class K, class V, std::size_t maxLength>
struct RobinHashTable
{
using CellIdx = typename uint_t<(maxLength < 0xFFFE)>::type;
alignas(8) KV_struct<K,V, (sizeof(K) % 8 < 7)> KV;
};


Which version is better depends on the situation and is up to some degree a matter of taste. From my understanding, both version can be considered as "Design by Introspection" and allow
"Up to 2^n possible interfaces, in compact form!".
So I am not really convinced that "if constexpr" must not introduce a scope.