common.h#
Portability macros for exception handling and class rule-of-five enforcement.
Provides two groups of macros:
Exception-handling macros (ONNX_THROW, ONNX_THROW_EX, ONNX_TRY, ONNX_CATCH, ONNX_HANDLE_EXCEPTION) that transparently switch between C++ exceptions and abort()-based termination depending on whether
ONNX_NO_EXCEPTIONSis defined.Copy/move-deletion macros (ONNX_DISALLOW_COPY, ONNX_DISALLOW_ASSIGNMENT, ONNX_DISALLOW_MOVE, ONNX_DISALLOW_COPY_AND_ASSIGNMENT, ONNX_DISALLOW_COPY_ASSIGNMENT_AND_MOVE) that delete the corresponding special-member functions in a class body.
Defines
-
ONNX_UNUSED_PARAMETER(x)#
Suppresses compiler warnings about an unreferenced function parameter.
Casts
xtovoidso that compilers do not emit an unused-parameter diagnostic. Use this in function bodies where a parameter is intentionally left unused (e.g. in a no-op override or a debug-only code path).- Parameters:
x – The parameter name to mark as intentionally unused.
-
ONNX_THROW(...)#
-
ONNX_THROW_EX(ex)#
-
ONNX_TRY#
-
ONNX_CATCH(x)#
-
ONNX_HANDLE_EXCEPTION(func)#
-
ONNX_DISALLOW_COPY(TypeName)#
Deletes the copy constructor of
TypeName.Place inside a class body to prevent copy construction. Typically used together with ONNX_DISALLOW_ASSIGNMENT.
- Parameters:
TypeName – The unqualified name of the enclosing class.
-
ONNX_DISALLOW_ASSIGNMENT(TypeName)#
Deletes the copy-assignment operator of
TypeName.Place inside a class body to prevent copy assignment. Typically used together with ONNX_DISALLOW_COPY.
- Parameters:
TypeName – The unqualified name of the enclosing class.
-
ONNX_DISALLOW_COPY_AND_ASSIGNMENT(TypeName)#
Deletes both the copy constructor and copy-assignment operator of
TypeName.Expands to ONNX_DISALLOW_COPY followed by ONNX_DISALLOW_ASSIGNMENT, making the class non-copyable.
- Parameters:
TypeName – The unqualified name of the enclosing class.
-
ONNX_DISALLOW_MOVE(TypeName)#
Deletes both the move constructor and move-assignment operator of
TypeName.Place inside a class body to prevent move construction and move assignment, making the class immovable.
- Parameters:
TypeName – The unqualified name of the enclosing class.
-
ONNX_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(TypeName)#
Deletes all copy and move special-member functions of
TypeName.Expands to ONNX_DISALLOW_COPY_AND_ASSIGNMENT followed by ONNX_DISALLOW_MOVE, making the class neither copyable nor movable.
- Parameters:
TypeName – The unqualified name of the enclosing class.