C++17: std::shared_mutex, interface_sizes, void_t, std::bool_constant, logical operation metafunctions

Class shared_mutex

On some platforms shared_mutex is more effecient then shared_timed_mutex.

In C++17 was added shared_mutex.

Example of usage:

Interface sizes

In C++17 were added two variables:

Destructive interference size: a number that’s suitable as an offset between two objects to likely avoid false-sharing due to different runtime access patterns from different threads.

Constructive interference size: a number that’s suitable as a limit on two objects’ combined memory footprint size and base alignment to likely promote true-sharing between them.

Variables are used with alignas. For example:


alias template void_t

void_t is used for simplify usage of SFINAE. void_t is declared like:

For example:


Alias template std::bool_constant

std::bool_constant it’s syntax sugar in C++17. For example:


Logical operation metafunctions

In C++17 were added Variadic metafunctions conjunction, disjunction, and negation for metaprogramming. These traits short-circuit in the metaprogramming sense: template specializations that are not required to determine the result are not instantiated.

For example:

Leave a Reply

Your email address will not be published. Required fields are marked *