micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T > Struct Template Reference

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

#include "micro-os-plus/micro-test-plus.h"

Inheritance diagram for micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T >:

Public Member Functions

constexpr nothrow_ (const Callable_T &func)
 Constructs a nothrow checking operator for the given callable.
constexpr operator bool () const
 Conversion operator to boolean.

Private Attributes

const bool value_ {}
 Stores the result of the callable invocation.

Detailed Description

template<class Callable_T>
struct micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T >

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_TThe type of the callable object to be invoked.

Definition at line 710 of file detail.h.

Constructor & Destructor Documentation

◆ nothrow_()

template<class Callable_T>
micro_os_plus::micro_test_plus::detail::nothrow_< Callable_T >::nothrow_ ( const Callable_T & func)
explicitconstexpr
Parameters
funcThe 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.

Definition at line 628 of file detail-inlines.h.

629 : callable_op_{ [&func]
630 {
631 try
632 {
633 func ();
634 }
635 catch (...)
636 {
637 return false;
638 }
639 return true;
640 }() }
641 {
642 }
constexpr callable_op_(bool value)
Constructs a callable operator with the pre-computed boolean result.
Operator struct template to check if an expression does not throw any exception.
Definition detail.h:711

References micro_os_plus::micro_test_plus::detail::callable_op_::callable_op_(), and nothrow_().

Referenced by nothrow_().

Member Function Documentation

◆ operator bool()

micro_os_plus::micro_test_plus::detail::callable_op_::operator bool ( ) const
nodiscardconstexprinherited
Parameters
None.
Returns
The result of the callable invocation.

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

Definition at line 554 of file detail-inlines.h.

556 {
557 return value_;
558 }
const bool value_
Stores the result of the callable invocation.
Definition detail.h:630

References value_.

Member Data Documentation

◆ value_

const bool micro_os_plus::micro_test_plus::detail::callable_op_::value_ {}
privateinherited

Definition at line 630 of file detail.h.

630{};

Referenced by callable_op_(), and operator bool().


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