Search code examples
c++mutexatomicstandard-librarystandard-layout

What is the purpose of standard-layout guarantees for "black box" types?


The C++ standard specifies that mutex, atomics or conditinal_variable are of standard-layout type.

What is the benefit of this specification? How a user can take advantage of this property?

And in general, what could I gain if a know a type is standard-layout without knowing the detail of its implementation?


Solution

  • You could make your code talk with other programs, written in different Programming Languages than yours.

    The ref mentions C++ concepts: StandardLayoutType:

    Standard layout types are useful for communicating with code written in other programming languages.