Skip to content

Commit 2229923

Browse files
authored
Update docs for _CCCL_IF_CONSTEVAL (#6692)
1 parent e048b61 commit 2229923

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/cccl/development/macro.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,20 @@ Usage example:
330330
| ``_CCCL_PRAGMA_NOUNROLL()`` | Portable ``#pragma nounroll`` pragma |
331331
+--------------------------------+-------------------------------------------+
332332

333+
**Conditional Constant Evaluation Macros**
334+
335+
In C++23, the ``if consteval`` statement (`link <https://en.cppreference.com/w/cpp/language/if.html>`_) was introduced. CCCL mimics the behaviour with a set of macros that expand to an implementation supported by the compiler. If the compiler doesn't support any kind of conditional constant evaluation, the macros expand to predefined fallback values.
336+
337+
+------------------------------------+-----------------------------------------------------------------------------------+
338+
| ``_CCCL_IF_CONSTEVAL`` | Equivalent to ``if consteval`` statement (fallbacks to ``if constexpr (false)``) |
339+
+------------------------------------+-----------------------------------------------------------------------------------+
340+
| ``_CCCL_IF_CONSTEVAL_DEFAULT`` | Equivalent to ``if consteval`` statement (fallbacks to ``if constexpr (true)``) |
341+
+------------------------------------+-----------------------------------------------------------------------------------+
342+
| ``_CCCL_IF_NOT_CONSTEVAL`` | Equivalent to ``if !consteval`` statement (fallbacks to ``if constexpr (true)``) |
343+
+------------------------------------+-----------------------------------------------------------------------------------+
344+
| ``_CCCL_IF_NOT_CONSTEVAL_DEFAULT`` | Equivalent to ``if !consteval`` statement (fallbacks to ``if constexpr (false)``) |
345+
+------------------------------------+-----------------------------------------------------------------------------------+
346+
333347
**Exception Macros**
334348

335349
CUDA doesn't support exceptions in device code, however, sometimes we need to write host/device functions that use exceptions on host and ``__trap()`` on device. CCCL provides a set of macros that should be used in place of the standard C++ keywords to make the code compile in both, host and device code.

0 commit comments

Comments
 (0)