I Am There, but I Am Not

emmtrix Tech Posts: Work & Fun with C++ Standard
Category: Knowledge

Not everything that is there in the standard, can be visible in the development.

C++ standard library defines a class array (std::array). The most vital part of the std::array is its member variable elems. This member contains the data, and what can be more important than data for one container (see image below).

However, in the standard the member is marked as exposition only. Why is this so?

This indicates that the member is inaccessible from the user code. The reason for marking elems as exposition only is to allow the implementation of std::array to be changed without breaking user code that relies upon it.

In general, exposing implementation details in a public API is not a good practice, as it can limit the ability of the library implementers to make changes and optimizations without breaking user code.

However, there are other ways to indirectly access elems in the user code.

Task: Name at least one way and lift the burden of the developer’s life.

___

Read on if you want to know the solution to the tasks…

Cookie Consent with Real Cookie Banner