Dune Core Modules (unstable)

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.

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

Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Nov 2, 23:43, 2025)