LvArray
Classes | Macros | Typedefs
Macros.hpp File Reference

Contains a bunch of macro definitions. More...

#include "LvArrayConfig.hpp"
#include "system.hpp"
#include <fstream>
#include <sstream>
#include <iostream>
#include <type_traits>
#include <cassert>
#include <RAJA/RAJA.hpp>
Include dependency graph for Macros.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RAJAHelper< typename >
 
struct  RAJAHelper< serialPolicy >
 

Macros

#define LVARRAY_FORCE_INLINE   inline
 Marks a function/lambda for inlining.
 
#define STRINGIZE_NX(A)   #A
 Convert A into a string. More...
 
#define STRINGIZE(A)   STRINGIZE_NX( A )
 Convert the macro expansion of A into a string. More...
 
#define LVARRAY_UNUSED_ARG(X)
 Mark X as an unused argument, used to silence compiler warnings. More...
 
#define LVARRAY_UNUSED_VARIABLE(X)   ( ( void ) X )
 Mark X as an unused variable, used to silence compiler warnings. More...
 
#define LVARRAY_DEBUG_VAR(X)   LVARRAY_UNUSED_VARIABLE( X )
 Mark X as an debug variable, used to silence compiler warnings. More...
 
#define LOCATION   __FILE__ ":" STRINGIZE( __LINE__ )
 Expands to a string representing the current file and line.
 
#define TYPEOFPTR(X)   std::remove_pointer_t< decltype( X ) >
 Given an expression X that evaluates to a pointer, expands to the type pointed to. More...
 
#define TYPEOFREF(X)   std::remove_reference_t< decltype( X ) >
 Given an expression X that evaluates to a reference, expands to the type referred to. More...
 
#define LVARRAY_LOG(...)   std::cout << __VA_ARGS__ << std::endl
 Print the expression.
 
#define LVARRAY_LOG_VAR(...)   LVARRAY_LOG( STRINGIZE( __VA_ARGS__ ) << " = " << __VA_ARGS__ )
 Print the expression string along with its value.
 
#define LVARRAY_ERROR_IF(EXP, MSG)
 Abort execution if EXP is true. More...
 
#define LVARRAY_ERROR(MSG)   LVARRAY_ERROR_IF( true, MSG )
 Abort execution. More...
 
#define LVARRAY_ASSERT_MSG(EXP, MSG)   LVARRAY_ERROR_IF( !(EXP), MSG )
 Abort execution if EXP is false but only when NDEBUG is not defined.. More...
 
#define LVARRAY_THROW_IF(EXP, MSG, TYPE)
 Conditionally throw an exception. More...
 
#define LVARRAY_THROW(MSG, TYPE)   LVARRAY_THROW_IF( true, MSG, TYPE )
 Throw an exception. More...
 
#define LVARRAY_ASSERT(EXP)   LVARRAY_ASSERT_MSG( EXP, "" )
 Assert EXP is true with no message.
 
#define LVARRAY_WARNING_IF(EXP, MSG)
 Print a warning if EXP is true. More...
 
#define LVARRAY_WARNING(MSG)   LVARRAY_WARNING_IF( true, MSG )
 Print a warning with a message. More...
 
#define LVARRAY_INFO_IF(EXP, MSG)
 Print msg along with the location if EXP is true. More...
 
#define LVARRAY_INFO(msg)   LVARRAY_INFO_IF( true, msg )
 Print msg along with the location. More...
 
#define LVARRAY_ERROR_IF_OP_MSG(lhs, OP, NOP, rhs, msg)
 Abort execution if lhs OP rhs. More...
 
#define LVARRAY_THROW_IF_OP_MSG(lhs, OP, NOP, rhs, msg, TYPE)
 Throw an exception if lhs OP rhs. More...
 
#define LVARRAY_ERROR_IF_EQ_MSG(lhs, rhs, msg)   LVARRAY_ERROR_IF_OP_MSG( lhs, ==, !=, rhs, msg )
 Raise a hard error if two values are equal. More...
 
#define LVARRAY_THROW_IF_EQ_MSG(lhs, rhs, msg, TYPE)   LVARRAY_THROW_IF_OP_MSG( lhs, ==, !=, rhs, msg, TYPE )
 Throw an exception if two values are equal. More...
 
#define LVARRAY_ERROR_IF_EQ(lhs, rhs)   LVARRAY_ERROR_IF_EQ_MSG( lhs, rhs, "" )
 Raise a hard error if two values are equal. More...
 
#define LVARRAY_THROW_IF_EQ(lhs, rhs, TYPE)   LVARRAY_THROW_IF_EQ_MSG( lhs, rhs, "", TYPE )
 Throw an exception if two values are equal. More...
 
#define LVARRAY_ERROR_IF_NE_MSG(lhs, rhs, msg)   LVARRAY_ERROR_IF_OP_MSG( lhs, !=, ==, rhs, msg )
 Raise a hard error if two values are not equal. More...
 
#define LVARRAY_THROW_IF_NE_MSG(lhs, rhs, msg, TYPE)   LVARRAY_THROW_IF_OP_MSG( lhs, !=, ==, rhs, msg, TYPE )
 Throw an exception if two values are not equal. More...
 
#define LVARRAY_ERROR_IF_NE(lhs, rhs)   LVARRAY_ERROR_IF_NE_MSG( lhs, rhs, "" )
 Raise a hard error if two values are not equal. More...
 
#define LVARRAY_THROW_IF_NE(lhs, rhs, TYPE)   LVARRAY_THROW_IF_NE_MSG( lhs, rhs, "", TYPE )
 Throw an exception if two values are not equal. More...
 
#define LVARRAY_ERROR_IF_GT_MSG(lhs, rhs, msg)   LVARRAY_ERROR_IF_OP_MSG( lhs, >, <=, rhs, msg )
 Raise a hard error if one value compares greater than the other. More...
 
#define LVARRAY_THROW_IF_GT_MSG(lhs, rhs, msg, TYPE)   LVARRAY_THROW_IF_OP_MSG( lhs, >, <=, rhs, msg, TYPE )
 Throw an exception if one value compares greater than the other. More...
 
#define LVARRAY_ERROR_IF_GT(lhs, rhs)   LVARRAY_ERROR_IF_GT_MSG( lhs, rhs, "" )
 Raise a hard error if one value compares greater than the other. More...
 
#define LVARRAY_THROW_IF_GT(lhs, rhs, TYPE)   LVARRAY_THROW_IF_GT_MSG( lhs, rhs, "", TYPE )
 Throw an exception if one value compares greater than the other. More...
 
#define LVARRAY_ERROR_IF_GE_MSG(lhs, rhs, msg)   LVARRAY_ERROR_IF_OP_MSG( lhs, >=, <, rhs, msg )
 Raise a hard error if one value compares greater than or equal to the other. More...
 
#define LVARRAY_THROW_IF_GE_MSG(lhs, rhs, msg, TYPE)   LVARRAY_THROW_IF_OP_MSG( lhs, >=, <, rhs, msg, TYPE )
 Throw an exception if one value compares greater than or equal to the other. More...
 
#define LVARRAY_ERROR_IF_GE(lhs, rhs)   LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "" )
 Raise a hard error if one value compares greater than or equal to the other. More...
 
#define LVARRAY_THROW_IF_GE(lhs, rhs, TYPE)   LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "", TYPE )
 Throw an exception if one value compares greater than or equal to the other. More...
 
#define LVARRAY_ERROR_IF_LT_MSG(lhs, rhs, msg)   LVARRAY_ERROR_IF_OP_MSG( lhs, <, >=, rhs, msg )
 Raise a hard error if one value compares less than the other. More...
 
#define LVARRAY_THROW_IF_LT_MSG(lhs, rhs, msg, TYPE)   LVARRAY_THROW_IF_OP_MSG( lhs, <, >=, rhs, msg, TYPE )
 Throw an exception if one value compares less than the other. More...
 
#define LVARRAY_ERROR_IF_LT(lhs, rhs)   LVARRAY_ERROR_IF_LT_MSG( lhs, rhs, "" )
 Raise a hard error if one value compares less than the other. More...
 
#define LVARRAY_THROW_IF_LT(lhs, rhs, TYPE)   LVARRAY_THROW_IF_LT_MSG( lhs, rhs, "", TYPE )
 Throw an exception if one value compares less than the other. More...
 
#define LVARRAY_ERROR_IF_LE_MSG(lhs, rhs, msg)   LVARRAY_ERROR_IF_OP_MSG( lhs, <=, >, rhs, msg )
 Raise a hard error if one value compares less than or equal to the other. More...
 
#define LVARRAY_THROW_IF_LE_MSG(lhs, rhs, msg, TYPE)   LVARRAY_THROW_IF_OP_MSG( lhs, <=, >, rhs, msg, TYPE )
 Throw an exception if one value compares less than or equal to the other. More...
 
#define LVARRAY_ERROR_IF_LE(lhs, rhs)   LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "" )
 Raise a hard error if one value compares less than or equal to the other. More...
 
#define LVARRAY_THROW_IF_LE(lhs, rhs, TYPE)   LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "", TYPE )
 Throw an exception if one value compares less than or equal to the other. More...
 
#define LVARRAY_ASSERT_OP_MSG(lhs, OP, rhs, msg)
 Abort execution if lhs OP rhs is false. More...
 
#define LVARRAY_ASSERT_EQ_MSG(lhs, rhs, msg)   LVARRAY_ASSERT_OP_MSG( lhs, ==, rhs, msg )
 Assert that two values compare equal in debug builds. More...
 
#define LVARRAY_ASSERT_EQ(lhs, rhs)   LVARRAY_ASSERT_EQ_MSG( lhs, rhs, "" )
 Assert that two values compare equal in debug builds. More...
 
#define LVARRAY_ASSERT_NE_MSG(lhs, rhs, msg)   LVARRAY_ASSERT_OP_MSG( lhs, !=, rhs, msg )
 Assert that two values compare not equal in debug builds. More...
 
#define LVARRAY_ASSERT_NE(lhs, rhs)   LVARRAY_ASSERT_NE_MSG( lhs, rhs, "" )
 Assert that two values compare not equal in debug builds. More...
 
#define LVARRAY_ASSERT_GT_MSG(lhs, rhs, msg)   LVARRAY_ASSERT_OP_MSG( lhs, >, rhs, msg )
 Assert that one value compares greater than the other in debug builds. More...
 
#define LVARRAY_ASSERT_GT(lhs, rhs)   LVARRAY_ASSERT_GT_MSG( lhs, rhs, "" )
 Assert that one value compares greater than the other in debug builds. More...
 
#define LVARRAY_ASSERT_GE_MSG(lhs, rhs, msg)   LVARRAY_ASSERT_OP_MSG( lhs, >=, rhs, msg )
 Assert that one value compares greater than or equal to the other in debug builds. More...
 
#define LVARRAY_ASSERT_GE(lhs, rhs)   LVARRAY_ASSERT_GE_MSG( lhs, rhs, "" )
 Assert that one value compares greater than or equal to the other in debug builds. More...
 
#define LVARRAY_HOST_DEVICE
 Mark a function for both host and device usage.
 
#define LVARRAY_HOST_DEVICE_HIP
 Mark a function for both host and device usage when using HIP only.
 
#define LVARRAY_DEVICE
 Mark a function for only device usage.
 
#define DISABLE_HD_WARNING
 Disable host device warnings. More...
 
#define CONSTEXPR_WITHOUT_BOUNDS_CHECK   constexpr
 Expands to constexpr when array bound checking is disabled.
 
#define CONSTEXPR_WITH_NDEBUG
 Expands to constexpr in release builds (when NDEBUG is defined).
 
#define CONSTEXPR_WITHOUT_BOUNDS_CHECK   constexpr
 Expands to constexpr when array bound checking is disabled.
 
#define CONSTEXPR_WITH_NDEBUG
 Expands to constexpr in release builds (when NDEBUG is defined).
 

Typedefs

using serialPolicy = RAJA::loop_exec
 

Detailed Description

Contains a bunch of macro definitions.

Macro Definition Documentation

◆ DISABLE_HD_WARNING

#define DISABLE_HD_WARNING

Disable host device warnings.

This pragma disables nvcc warnings about calling a host function from a host-device function. This is used on templated host-device functions where some template instantiations call host only code. This is safe as long as the host only instantiations are only called on the host. To use place directly above a the template.

◆ LVARRAY_ASSERT_EQ

#define LVARRAY_ASSERT_EQ (   lhs,
  rhs 
)    LVARRAY_ASSERT_EQ_MSG( lhs, rhs, "" )

Assert that two values compare equal in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ASSERT_EQ_MSG

#define LVARRAY_ASSERT_EQ_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ASSERT_OP_MSG( lhs, ==, rhs, msg )

Assert that two values compare equal in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ASSERT_GE

#define LVARRAY_ASSERT_GE (   lhs,
  rhs 
)    LVARRAY_ASSERT_GE_MSG( lhs, rhs, "" )

Assert that one value compares greater than or equal to the other in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ASSERT_GE_MSG

#define LVARRAY_ASSERT_GE_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ASSERT_OP_MSG( lhs, >=, rhs, msg )

Assert that one value compares greater than or equal to the other in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ASSERT_GT

#define LVARRAY_ASSERT_GT (   lhs,
  rhs 
)    LVARRAY_ASSERT_GT_MSG( lhs, rhs, "" )

Assert that one value compares greater than the other in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ASSERT_GT_MSG

#define LVARRAY_ASSERT_GT_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ASSERT_OP_MSG( lhs, >, rhs, msg )

Assert that one value compares greater than the other in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ASSERT_MSG

#define LVARRAY_ASSERT_MSG (   EXP,
  MSG 
)    LVARRAY_ERROR_IF( !(EXP), MSG )

Abort execution if EXP is false but only when NDEBUG is not defined..

Parameters
EXPThe expression to check.
MSGThe message to associate with the error, can be anything streamable to a std::ostream.
Note
This macro can be used in both host and device code.
Tries to provide as much information about the location of the error as possible. On host this should result in the file and line of the error and a stack trace along with the provided message. On device none of this is guaranteed. In fact it is only guaranteed to abort the current kernel.

◆ LVARRAY_ASSERT_NE

#define LVARRAY_ASSERT_NE (   lhs,
  rhs 
)    LVARRAY_ASSERT_NE_MSG( lhs, rhs, "" )

Assert that two values compare not equal in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ASSERT_NE_MSG

#define LVARRAY_ASSERT_NE_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ASSERT_OP_MSG( lhs, !=, rhs, msg )

Assert that two values compare not equal in debug builds.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ASSERT_OP_MSG

#define LVARRAY_ASSERT_OP_MSG (   lhs,
  OP,
  rhs,
  msg 
)
Value:
LVARRAY_ASSERT_MSG( lhs OP rhs, \
msg << "\n" << \
" " << #lhs << " = " << lhs << "\n" << \
" " << #rhs << " = " << rhs << "\n" )
#define LVARRAY_ASSERT_MSG(EXP, MSG)
Abort execution if EXP is false but only when NDEBUG is not defined..
Definition: Macros.hpp:190

Abort execution if lhs OP rhs is false.

Parameters
lhsThe left side of the operation.
OPThe operation to apply.
rhsThe right side of the operation.
msgThe message to diplay.

◆ LVARRAY_DEBUG_VAR

#define LVARRAY_DEBUG_VAR (   X)    LVARRAY_UNUSED_VARIABLE( X )

Mark X as an debug variable, used to silence compiler warnings.

Parameters
Xthe debug variable.

◆ LVARRAY_ERROR

#define LVARRAY_ERROR (   MSG)    LVARRAY_ERROR_IF( true, MSG )

Abort execution.

Parameters
MSGThe message to associate with the error, can be anything streamable to a std::ostream.

◆ LVARRAY_ERROR_IF

#define LVARRAY_ERROR_IF (   EXP,
  MSG 
)
Value:
do \
{ \
if( EXP ) \
{ \
std::ostringstream __oss; \
__oss << "***** ERROR\n"; \
__oss << "***** LOCATION: " LOCATION "\n"; \
__oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \
__oss << MSG << "\n"; \
__oss << LvArray::system::stackTrace( true ); \
std::cout << __oss.str() << std::endl; \
LvArray::system::callErrorHandler(); \
} \
} while( false )
std::string stackTrace(bool const location)
Return a demangled stack trace of the last 25 frames.
Definition: system.cpp:361
#define STRINGIZE(A)
Convert the macro expansion of A into a string.
Definition: Macros.hpp:67
#define LOCATION
Expands to a string representing the current file and line.
Definition: Macros.hpp:88

Abort execution if EXP is true.

Parameters
EXPThe expression to check.
MSGThe message to associate with the error, can be anything streamable to a std::ostream.
Note
This macro can be used in both host and device code.
Tries to provide as much information about the location of the error as possible. On host this should result in the file and line of the error and a stack trace along with the provided message. On device none of this is guaranteed. In fact it is only guaranteed to abort the current kernel.

◆ LVARRAY_ERROR_IF_EQ

#define LVARRAY_ERROR_IF_EQ (   lhs,
  rhs 
)    LVARRAY_ERROR_IF_EQ_MSG( lhs, rhs, "" )

Raise a hard error if two values are equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ERROR_IF_EQ_MSG

#define LVARRAY_ERROR_IF_EQ_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ERROR_IF_OP_MSG( lhs, ==, !=, rhs, msg )

Raise a hard error if two values are equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ERROR_IF_GE

#define LVARRAY_ERROR_IF_GE (   lhs,
  rhs 
)    LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "" )

Raise a hard error if one value compares greater than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ERROR_IF_GE_MSG

#define LVARRAY_ERROR_IF_GE_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ERROR_IF_OP_MSG( lhs, >=, <, rhs, msg )

Raise a hard error if one value compares greater than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ERROR_IF_GT

#define LVARRAY_ERROR_IF_GT (   lhs,
  rhs 
)    LVARRAY_ERROR_IF_GT_MSG( lhs, rhs, "" )

Raise a hard error if one value compares greater than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ERROR_IF_GT_MSG

#define LVARRAY_ERROR_IF_GT_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ERROR_IF_OP_MSG( lhs, >, <=, rhs, msg )

Raise a hard error if one value compares greater than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ERROR_IF_LE

#define LVARRAY_ERROR_IF_LE (   lhs,
  rhs 
)    LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "" )

Raise a hard error if one value compares less than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ERROR_IF_LE_MSG

#define LVARRAY_ERROR_IF_LE_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ERROR_IF_OP_MSG( lhs, <=, >, rhs, msg )

Raise a hard error if one value compares less than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ERROR_IF_LT

#define LVARRAY_ERROR_IF_LT (   lhs,
  rhs 
)    LVARRAY_ERROR_IF_LT_MSG( lhs, rhs, "" )

Raise a hard error if one value compares less than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ERROR_IF_LT_MSG

#define LVARRAY_ERROR_IF_LT_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ERROR_IF_OP_MSG( lhs, <, >=, rhs, msg )

Raise a hard error if one value compares less than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ERROR_IF_NE

#define LVARRAY_ERROR_IF_NE (   lhs,
  rhs 
)    LVARRAY_ERROR_IF_NE_MSG( lhs, rhs, "" )

Raise a hard error if two values are not equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison

◆ LVARRAY_ERROR_IF_NE_MSG

#define LVARRAY_ERROR_IF_NE_MSG (   lhs,
  rhs,
  msg 
)    LVARRAY_ERROR_IF_OP_MSG( lhs, !=, ==, rhs, msg )

Raise a hard error if two values are not equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)

◆ LVARRAY_ERROR_IF_OP_MSG

#define LVARRAY_ERROR_IF_OP_MSG (   lhs,
  OP,
  NOP,
  rhs,
  msg 
)
Value:
LVARRAY_ERROR_IF( lhs OP rhs, \
msg << "\n" << \
"Expected " << #lhs << " " << #NOP << " " << #rhs << "\n" << \
" " << #lhs << " = " << lhs << "\n" << \
" " << #rhs << " = " << rhs << "\n" )
#define LVARRAY_ERROR_IF(EXP, MSG)
Abort execution if EXP is true.
Definition: Macros.hpp:155

Abort execution if lhs OP rhs.

Parameters
lhsThe left side of the operation.
OPThe operation to apply.
NOPThe opposite of OP, used in the message.
rhsThe right side of the operation.
msgThe message to diplay.

◆ LVARRAY_INFO

#define LVARRAY_INFO (   msg)    LVARRAY_INFO_IF( true, msg )

Print msg along with the location.

Parameters
msgThe message to print.

◆ LVARRAY_INFO_IF

#define LVARRAY_INFO_IF (   EXP,
  MSG 
)
Value:
do \
{ \
if( EXP ) \
{ \
std::ostringstream __oss; \
__oss << "***** INFO\n"; \
__oss << "***** LOCATION: " LOCATION "\n"; \
__oss << "***** Controlling expression: " STRINGIZE( EXP ) "\n"; \
__oss << MSG; \
std::cout << __oss.str() << std::endl; \
} \
} while( false )
#define STRINGIZE(A)
Convert the macro expansion of A into a string.
Definition: Macros.hpp:67
#define LOCATION
Expands to a string representing the current file and line.
Definition: Macros.hpp:88

Print msg along with the location if EXP is true.

Parameters
EXPThe expression to test.
MSGThe message to print.

◆ LVARRAY_THROW

#define LVARRAY_THROW (   MSG,
  TYPE 
)    LVARRAY_THROW_IF( true, MSG, TYPE )

Throw an exception.

Parameters
MSGThe message to associate with the error, can be anything streamable to a std::ostream.

◆ LVARRAY_THROW_IF

#define LVARRAY_THROW_IF (   EXP,
  MSG,
  TYPE 
)
Value:
do \
{ \
if( EXP ) \
{ \
std::ostringstream __oss; \
__oss << "\n"; \
__oss << "***** LOCATION: " LOCATION "\n"; \
__oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \
__oss << MSG << "\n"; \
__oss << LvArray::system::stackTrace( true ); \
throw TYPE( __oss.str() ); \
} \
} while( false )
std::string stackTrace(bool const location)
Return a demangled stack trace of the last 25 frames.
Definition: system.cpp:361
#define STRINGIZE(A)
Convert the macro expansion of A into a string.
Definition: Macros.hpp:67
#define LOCATION
Expands to a string representing the current file and line.
Definition: Macros.hpp:88

Conditionally throw an exception.

Parameters
EXPan expression that will be evaluated as a predicate
MSGa message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_EQ

#define LVARRAY_THROW_IF_EQ (   lhs,
  rhs,
  TYPE 
)    LVARRAY_THROW_IF_EQ_MSG( lhs, rhs, "", TYPE )

Throw an exception if two values are equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_EQ_MSG

#define LVARRAY_THROW_IF_EQ_MSG (   lhs,
  rhs,
  msg,
  TYPE 
)    LVARRAY_THROW_IF_OP_MSG( lhs, ==, !=, rhs, msg, TYPE )

Throw an exception if two values are equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_GE

#define LVARRAY_THROW_IF_GE (   lhs,
  rhs,
  TYPE 
)    LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "", TYPE )

Throw an exception if one value compares greater than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_GE_MSG

#define LVARRAY_THROW_IF_GE_MSG (   lhs,
  rhs,
  msg,
  TYPE 
)    LVARRAY_THROW_IF_OP_MSG( lhs, >=, <, rhs, msg, TYPE )

Throw an exception if one value compares greater than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_GT

#define LVARRAY_THROW_IF_GT (   lhs,
  rhs,
  TYPE 
)    LVARRAY_THROW_IF_GT_MSG( lhs, rhs, "", TYPE )

Throw an exception if one value compares greater than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_GT_MSG

#define LVARRAY_THROW_IF_GT_MSG (   lhs,
  rhs,
  msg,
  TYPE 
)    LVARRAY_THROW_IF_OP_MSG( lhs, >, <=, rhs, msg, TYPE )

Throw an exception if one value compares greater than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_LE

#define LVARRAY_THROW_IF_LE (   lhs,
  rhs,
  TYPE 
)    LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "", TYPE )

Throw an exception if one value compares less than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_LE_MSG

#define LVARRAY_THROW_IF_LE_MSG (   lhs,
  rhs,
  msg,
  TYPE 
)    LVARRAY_THROW_IF_OP_MSG( lhs, <=, >, rhs, msg, TYPE )

Throw an exception if one value compares less than or equal to the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_LT

#define LVARRAY_THROW_IF_LT (   lhs,
  rhs,
  TYPE 
)    LVARRAY_THROW_IF_LT_MSG( lhs, rhs, "", TYPE )

Throw an exception if one value compares less than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_LT_MSG

#define LVARRAY_THROW_IF_LT_MSG (   lhs,
  rhs,
  msg,
  TYPE 
)    LVARRAY_THROW_IF_OP_MSG( lhs, <, >=, rhs, msg, TYPE )

Throw an exception if one value compares less than the other.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_NE

#define LVARRAY_THROW_IF_NE (   lhs,
  rhs,
  TYPE 
)    LVARRAY_THROW_IF_NE_MSG( lhs, rhs, "", TYPE )

Throw an exception if two values are not equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_NE_MSG

#define LVARRAY_THROW_IF_NE_MSG (   lhs,
  rhs,
  msg,
  TYPE 
)    LVARRAY_THROW_IF_OP_MSG( lhs, !=, ==, rhs, msg, TYPE )

Throw an exception if two values are not equal.

Parameters
lhsexpression to be evaluated and used as left-hand side in comparison
rhsexpression to be evaluated and used as right-hand side in comparison
msga message to log (any expression that can be stream inserted)
TYPEthe type of exception to throw

◆ LVARRAY_THROW_IF_OP_MSG

#define LVARRAY_THROW_IF_OP_MSG (   lhs,
  OP,
  NOP,
  rhs,
  msg,
  TYPE 
)
Value:
LVARRAY_THROW_IF( lhs OP rhs, \
msg << "\n" << \
"Expected " << #lhs << " " << #NOP << " " << #rhs << "\n" << \
" " << #lhs << " = " << lhs << "\n" << \
" " << #rhs << " = " << rhs << "\n", TYPE )
#define LVARRAY_THROW_IF(EXP, MSG, TYPE)
Conditionally throw an exception.
Definition: Macros.hpp:201

Throw an exception if lhs OP rhs.

Parameters
lhsThe left side of the operation.
OPThe operation to apply.
NOPThe opposite of OP, used in the message.
rhsThe right side of the operation.
msgThe message to diplay.
TYPEthe type of exception to throw.

◆ LVARRAY_UNUSED_ARG

#define LVARRAY_UNUSED_ARG (   X)

Mark X as an unused argument, used to silence compiler warnings.

Parameters
Xthe unused argument.

◆ LVARRAY_UNUSED_VARIABLE

#define LVARRAY_UNUSED_VARIABLE (   X)    ( ( void ) X )

Mark X as an unused variable, used to silence compiler warnings.

Parameters
Xthe unused variable.

◆ LVARRAY_WARNING

#define LVARRAY_WARNING (   MSG)    LVARRAY_WARNING_IF( true, MSG )

Print a warning with a message.

Parameters
MSGThe message to print.

◆ LVARRAY_WARNING_IF

#define LVARRAY_WARNING_IF (   EXP,
  MSG 
)
Value:
do \
{ \
if( EXP ) \
{ \
std::ostringstream __oss; \
__oss << "***** WARNING\n"; \
__oss << "***** LOCATION: " LOCATION "\n"; \
__oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \
__oss << MSG; \
std::cout << __oss.str() << std::endl; \
} \
} while( false )
#define STRINGIZE(A)
Convert the macro expansion of A into a string.
Definition: Macros.hpp:67
#define LOCATION
Expands to a string representing the current file and line.
Definition: Macros.hpp:88

Print a warning if EXP is true.

Parameters
EXPThe expression to check.
MSGThe message to associate with the warning, can be anything streamable to a std::ostream.

◆ STRINGIZE

#define STRINGIZE (   A)    STRINGIZE_NX( A )

Convert the macro expansion of A into a string.

Parameters
Athe token to convert to a string.

◆ STRINGIZE_NX

#define STRINGIZE_NX (   A)    #A

Convert A into a string.

Parameters
Athe token to convert to a string.

◆ TYPEOFPTR

#define TYPEOFPTR (   X)    std::remove_pointer_t< decltype( X ) >

Given an expression X that evaluates to a pointer, expands to the type pointed to.

Parameters
XThe expression to evaluate.

◆ TYPEOFREF

#define TYPEOFREF (   X)    std::remove_reference_t< decltype( X ) >

Given an expression X that evaluates to a reference, expands to the type referred to.

Parameters
XThe expression to evaluate.