Skip to main content

nothrow_ Struct Template

Operator struct template to check if an expression does not throw any exception. More...

Declaration

template <class Callable_T>
struct micro_os_plus::micro_test_plus::detail::nothrow_<Callable_T> { ... }

Included Headers

Base struct

structcallable_op_

Common base struct for callable-wrapping operators. More...

Public Constructors Index

template <class Callable_T>
constexprnothrow_ (const Callable_T &func)

Constructs a nothrow checking operator for the given callable. More...

Public Operators Index

template <class Callable_T>
constexproperator bool () const

Conversion operator to boolean. More...

Private Member Attributes Index

template <class Callable_T>
const boolvalue_ {}

Stores the result of the callable invocation. More...

Description

Operator struct template to check if an expression does not throw any exception.

This struct checks whether invoking the given callable completes without throwing an exception. The check is performed at construction time, with the result cached for reporting and composition. Use this when a test must verify that an operation is exception-safe.

Template Parameters
Callable_T

The type of the callable object to be invoked.

Definition at line 701 of file detail.h.

Public Constructors

nothrow_()

template <class Callable_T>
micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T >::nothrow_ (const Callable_T & func)
explicit constexpr

Constructs a nothrow checking operator for the given callable.

Parameters
func

The callable object to be invoked.

Invokes func inside a try/catch block. If func completes without throwing, the result is true; if any exception is thrown the result is false. The result is passed to the callable_op_ base class constructor.

Declaration at line 709 of file detail.h, definition at line 608 of file detail-inlines.h.

608 constexpr nothrow_<Callable_T>::nothrow_ (const Callable_T& func)
609 : callable_op_{ [&func]
610 {
611 try
612 {
613 func ();
614 }
615 catch (...)
616 {
617 return false;
618 }
619 return true;
620 }() }
621 {
622 }

References micro_os_plus::micro_test_plus::detail::callable_op_::callable_op_ and micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T >::nothrow_.

Referenced by micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T >::nothrow_.

Public Operators

operator bool()

template <class Callable_T>
micro_os_plus::micro_test_plus::detail::callable_op_::operator bool ()
nodiscard constexpr

Conversion operator to boolean.

Parameters

None.

Returns

The result of the callable invocation.

Returns the pre-computed boolean result stored by the derived operator's constructor.

Declaration at line 615 of file detail.h, definition at line 535 of file detail-inlines.h.

535 operator bool () const
536 {
537 return value_;
538 }

Reference micro_os_plus::micro_test_plus::detail::callable_op_::value_.

Private Member Attributes

value_

template <class Callable_T>
const bool micro_os_plus::micro_test_plus::detail::callable_op_::value_ {}

Stores the result of the callable invocation.

Definition at line 621 of file detail.h.

621 const bool value_{};

Referenced by micro_os_plus::micro_test_plus::detail::callable_op_::callable_op_ and micro_os_plus::micro_test_plus::detail::callable_op_::operator bool.


The documentation for this struct was generated from the following files:


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.