mirror of
https://github.com/boostorg/core.git
synced 2025-11-29 05:40:14 +01:00
Document BOOST_CORE_STATIC_ASSERT
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
and `std::size`, respectively, when the latter are provided by compiler. This resolves potential
|
and `std::size`, respectively, when the latter are provided by compiler. This resolves potential
|
||||||
ambiguities when both `boost::` and `std::` alternatives are found by the compiler, e.g. as a result
|
ambiguities when both `boost::` and `std::` alternatives are found by the compiler, e.g. as a result
|
||||||
of ADL. ([github_issue 206])
|
of ADL. ([github_issue 206])
|
||||||
|
* Added [link core.static_assert `BOOST_CORE_STATIC_ASSERT`], a reimplementation of `BOOST_STATIC_ASSERT`
|
||||||
|
for libraries that already depend on Core and would like to remove the dependency on StaticAssert.
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ criteria for inclusion is that the utility component be:
|
|||||||
[include serialization.qbk]
|
[include serialization.qbk]
|
||||||
[include size.qbk]
|
[include size.qbk]
|
||||||
[include span.qbk]
|
[include span.qbk]
|
||||||
|
[include static_assert.qbk]
|
||||||
[include swap.qbk]
|
[include swap.qbk]
|
||||||
[include typeinfo.qbk]
|
[include typeinfo.qbk]
|
||||||
[include type_name.qbk]
|
[include type_name.qbk]
|
||||||
|
|||||||
57
doc/static_assert.qbk
Normal file
57
doc/static_assert.qbk
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
[/
|
||||||
|
Copyright 2025 Peter Dimov
|
||||||
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
https://boost.org/LICENSE_1_0.txt
|
||||||
|
]
|
||||||
|
|
||||||
|
[section:static_assert static_assert]
|
||||||
|
|
||||||
|
[simplesect Authors]
|
||||||
|
|
||||||
|
* Peter Dimov
|
||||||
|
|
||||||
|
[endsimplesect]
|
||||||
|
|
||||||
|
[section Header <boost/core/static_assert.hpp>]
|
||||||
|
|
||||||
|
The header `<boost/core/static_assert.hpp>` defines
|
||||||
|
the macro `BOOST_CORE_STATIC_ASSERT(expr)`, which
|
||||||
|
expands to `static_assert(expr, #expr)` under C++11
|
||||||
|
or later, or to a suitable emulation under C++03.
|
||||||
|
|
||||||
|
The same functionality is provided by `BOOST_STATIC_ASSERT`
|
||||||
|
defined in `<boost/static_assert.hpp>`, and the macro
|
||||||
|
is duplicated here for libraries that already depend
|
||||||
|
on Core and would like to remove the dependency on
|
||||||
|
StaticAssert.
|
||||||
|
|
||||||
|
[section Synopsis]
|
||||||
|
|
||||||
|
``
|
||||||
|
#define BOOST_CORE_STATIC_ASSERT(expr) static_assert(expr, #expr)
|
||||||
|
``
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[section Example]
|
||||||
|
|
||||||
|
```
|
||||||
|
#include <boost/core/static_assert.hpp>
|
||||||
|
|
||||||
|
BOOST_CORE_STATIC_ASSERT( sizeof(char[1]) == 1 );
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
BOOST_CORE_STATIC_ASSERT( sizeof(char[2]) == 2 );
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_CORE_STATIC_ASSERT( sizeof(char[3]) == 3 );
|
||||||
|
}
|
||||||
|
```
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
[endsect]
|
||||||
Reference in New Issue
Block a user