Loading...
Searching...
No Matches
assume.hh File Reference

Provide the macro DUNE_ASSUME(...) that is a portable assume expression as a hint for the compiler/optimizer. If no equivalent to the assume attribute is available, it falls back to an assert() macro. More...

`#include <cassert>`

Go to the source code of this file.

## Macros

#define | DUNE_ASSUME(...)

## Detailed Description

Provide the macro DUNE_ASSUME(...) that is a portable assume expression as a hint for the compiler/optimizer. If no equivalent to the assume attribute is available, it falls back to an assert() macro.

A detailed explanation of portable assumptions is provided in the C++ standard proposal https://wg21.link/p1774r8.

Caution: Only use simple boolean expressions inside the DUNE_ASSUME macro. Especially, do not use expressions with side effects. Those could result in compiler-dependent behavior.

The implementation is inspired by https://stackoverflow.com/questions/63493968/reproducing-clangs-builtin-assume-for-gcc

## Macro Definition Documentation

## DUNE_ASSUME

#define DUNE_ASSUME | ( |  | ... | ) |

Value:
assert(bool(__VA_ARGS__))