AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
ConstexprAssert.hpp File Reference

A constexpr-friendly assertion for host/device code. More...

#include "axom/config.hpp"
#include "axom/core/utilities/Abort.hpp"
#include <cassert>
#include <type_traits>

Namespaces

 axom
 
 axom::detail
 

Macros

#define AXOM_DETAIL_CONSTEXPR_ASSERT_HOST_DEVICE
 
#define AXOM_DETAIL_HAS_IS_CONSTANT_EVALUATED   0
 

Functions

void axom::detail::constexprAssertFail (const char *, const char *, int)
 
constexpr void axom::detail::constexprAssert (bool cond, const char *expr, const char *file, int line)
 

Detailed Description

A constexpr-friendly assertion for host/device code.

This header provides the low-level implementation routine axom::detail::constexprAssert(bool, const char*, const char*, int).

Most Axom code should use the convenience macro AXOM_CONSTEXPR_ASSERT(EXP) (defined in axom/core/Macros.hpp), which forwards expression text and source location to axom::detail::constexprAssert(...).

Note
Rationale: Some debug assertion mechanisms use non-literal types (e.g. iostreams) and therefore cannot appear inside functions that must be usable in constant expressions under C++17. This facility provides an assertion-like hook that is valid in constexpr-capable code and remains device-compilable across Axom's supported backends.

Semantics:

  • If the condition is false during constant evaluation, compilation fails.
  • If the condition is false at run time and AXOM_DEBUG is enabled (host code), the process aborts.
  • In non-debug runtime builds, it is a no-op.
  • In device compilation, it is a no-op (kernels cannot throw/abort portably).

Macro Definition Documentation

◆ AXOM_DETAIL_CONSTEXPR_ASSERT_HOST_DEVICE

#define AXOM_DETAIL_CONSTEXPR_ASSERT_HOST_DEVICE

◆ AXOM_DETAIL_HAS_IS_CONSTANT_EVALUATED

#define AXOM_DETAIL_HAS_IS_CONSTANT_EVALUATED   0