Adder ff0ae13c64 integral_constant: MPL interop: Avoid one function-local static object.
If the compiler does not optimize away the `pdata` function-local `static` object,
it ends up occupying space in the data section
and it is going to need a corresponding relocation entry
(just in case the module is not loaded at the desired address,
as is the case with ASLR in Windows Vista and later and in modern versions of Linux).

I admit that, for the current code,
both MSVC and GCC manage to optimize away `pdata` even if it is `static`.

But Boost should be an example of good coding
which can be applied even to more complicated source code,
e.g. to source code which calls `opaque_function (&pdata)`
(in which case, if `pdata` is static, both MSVC and GCC do emit an extra relocation).

And for other more complex cases, a function-local static-storage-duration object
costs even more (as compared to a function-local automatic-storage-duration object
given C++11 rules for "thread-safe" initialization of function-local `static`s.

And I wish to re-iterate that, in my opinion,
a good way to cast a pointer-to-one-type to a pointer-to-an-unrelated-type
is not by `reinterpret_cast` (which by the way makes `pdata` not needed any more),
but by using pointer to (possibly cv-qualified) `void` as an intermediary pointer type:

```
return static_cast <const Target *> (static_cast <const void *> (pointer_to_source))
```

or:

```
const void *const intermediary (pointer_to_source); // Not `static` for the general case.
return static_cast <const Target *> (intermediary);
```

Therefore, if the authors kindly agree, we can make this code an example for this style.
2025-04-21 12:26:39 +01:00
2025-04-16 19:23:22 +01:00
2025-04-16 17:10:37 +01:00
2021-04-20 16:03:18 +00:00
2003-10-07 10:51:54 +00:00
2021-06-10 02:04:51 +03:00
2018-11-06 19:37:09 +00:00

Boost TypeTraits Library

The Boost type-traits library contains a set of very specific traits classes, each of which encapsulate a single trait from the C++ type system; for example, is a type a pointer or a reference type? Or does a type have a trivial constructor, or a const-qualifier?

The type-traits classes share a unified design: each class inherits from the type true_type if the type has the specified property and inherits from false_type otherwise.

The type-traits library also contains a set of classes that perform a specific transformation on a type; for example, they can remove a top-level const or volatile qualifier from a type. Each class that performs a transformation defines a single typedef-member type that is the result of the transformation.

The full documentation is available on boost.org.

Master Develop
Travis Build Status Build Status
Appveyor Build status Build status

Support, bugs and feature requests

Bugs and feature requests can be reported through the Gitub issue tracker (see open issues and closed issues).

You can submit your changes through a pull request.

There is no mailing-list specific to Boost TypeTraits, although you can use the general-purpose Boost mailing-list using the tag [type_traits].

Development

Clone the whole boost project, which includes the individual Boost projects as submodules (see boost+git doc):

git clone https://github.com/boostorg/boost
cd boost
git submodule update --init

The Boost TypeTraits Library is located in libs/type_traits/.

Running tests

First, make sure you are in libs/type_traits/test. You can either run all the tests listed in Jamfile.v2 or run a single test:

../../../b2                        <- run all tests
../../../b2 config_info            <- single test
S
Description
Boost.org type_traits module
Readme
5.3 MiB
Languages
C++ 99.9%