Global namespace

Namespaces

Name

Description

boost

Namespace boost

Namespaces

Name

Description

scope

Namespace scope

Types

Name

Description

always_true

A predicate that always returns true.

default_resource_t

error_code_checker

A predicate for checking whether an error code indicates error.

exception_checker

A predicate for checking whether an exception is being thrown.

fd_deleter

POSIX-like file descriptor deleter

fd_resource_traits

POSIX-like file descriptor resource traits

scope_exit

Scope exit guard that conditionally invokes a function upon leaving the scope.

scope_fail

Scope exit guard that invokes a function upon leaving the scope with a failure condition satisfied.

scope_final

Scope final guard that invokes a function upon leaving the scope.

scope_success

Scope exit guard that invokes a function upon leaving the scope with a failure condition not satisfied.

unique_fd

Unique POSIX-like file descriptor resource

unique_resource

RAII wrapper for automatically reclaiming arbitrary resources.

Functions

Name

Description

check_error_code

Creates a predicate for checking whether an exception is being thrown

check_exception

Creates a predicate for checking whether an exception is being thrown

make_scope_exit

Creates a scope guard with a given action function object.

make_scope_fail

Creates a scope fail guard with a given action function object.

make_scope_success

Creates a scope fail guard with a given action function object.

make_unique_resource_checked

Checks if the resource is valid and creates a unique_resource wrapper.

swap

Variables

Name

Description

default_resource

Keyword representing default, unallocated resource argument

Deduction Guides

Class error_code_checker

A predicate for checking whether an error code indicates error.

Synopsis

Declared in header <boost/scope/error_code_checker.hpp>

template<typename ErrorCode>
class error_code_checker;

Types

Name

Description

result_type

Predicate result type

Member Functions

Name

Description

error_code_checker

Constructs the predicate.

operator()

Checks if the error code indicates error.

Description

The predicate captures a reference to an external error code object, which it tests for an error indication when called. The error code object must remain valid for the whole lifetime duration of the predicate. For an error code object ec, an expression !ec must be valid, never throw exceptions, and return a value contextually convertible to bool. If the returned value converts to false, then this is taken as an error indication, and the predicate returns true. Otherwise, the predicate returns false. A few examples of error code types:

  • std::error_code or boost::system::error_code,

  • std::expected, boost::outcome_v2::basic_outcome or boost::outcome_v2::basic_result,

  • int, where the value of 0 indicates no error,

  • bool, where the value of false indicates no error,

  • T*, where a null pointer indicates no error.

error_code_checker::result_type

Predicate result type

Synopsis

Declared in header <boost/scope/error_code_checker.hpp>

typedef bool result_type;

Function error_code_checker::error_code_checker

Constructs the predicate.

Synopsis

Declared in header <boost/scope/error_code_checker.hpp>

error_code_checker(ErrorCode& ec) noexcept;

Description

Upon construction, the predicate saves a reference to the external error code object. The referenced object must remain valid for the whole lifetime duration of the predicate. Throws: Nothing.

Parameters

Name Type

ec

ErrorCode&

Function error_code_checker::operator()

Checks if the error code indicates error.

Synopsis

Declared in header <boost/scope/error_code_checker.hpp>

result_type
operator()() const noexcept;

Description

Throws: Nothing.

Return Value

Function check_error_code

Creates a predicate for checking whether an exception is being thrown

Synopsis

Declared in header <boost/scope/error_code_checker.hpp>

template<typename ErrorCode>
error_code_checker<ErrorCode>
check_error_code(ErrorCode& ec) noexcept;

Description

Throws: Nothing.

Return Value

Parameters

Name Type

ec

ErrorCode&

Class exception_checker

A predicate for checking whether an exception is being thrown.

Synopsis

Declared in header <boost/scope/exception_checker.hpp>

class exception_checker;

Types

Name

Description

result_type

Predicate result type

Member Functions

Name

Description

exception_checker

Constructs the predicate.

operator()

Checks if an exception is being thrown.

Description

On construction, the predicate captures the current number of uncaught exceptions, which it then compares with the number of uncaught exceptions at the point when it is called. If the number increased then a new exception is detected and the predicate returns true.

Note
This predicate is designed for a specific use case with scope guards created on the stack. It is incompatible with C++20 coroutines and similar facilities (e.g. fibers and userspace context switching), where the thread of execution may be suspended after the predicate captures the number of uncaught exceptions and then resumed in a different context, where the number of uncaught exceptions has changed. Similarly, it is incompatible with usage patterns where the predicate is cached after construction and is invoked after the thread has left the scope where the predicate was constructed (e.g. when the predicate is stored as a class data member or a namespace-scope variable).

exception_checker::result_type

Predicate result type

Synopsis

Declared in header <boost/scope/exception_checker.hpp>

typedef bool result_type;

Function exception_checker::exception_checker

Constructs the predicate.

Synopsis

Declared in header <boost/scope/exception_checker.hpp>

exception_checker() noexcept;

Description

Upon construction, the predicate saves the current number of uncaught exceptions. This information will be used when calling the predicate to detect if a new exception is being thrown. Throws: Nothing.

Function exception_checker::operator()

Checks if an exception is being thrown.

Synopsis

Declared in header <boost/scope/exception_checker.hpp>

result_type
operator()() const noexcept;

Description

Throws: Nothing.

Return Value

Function check_exception

Creates a predicate for checking whether an exception is being thrown

Synopsis

Declared in header <boost/scope/exception_checker.hpp>

exception_checker
check_exception() noexcept;

Description

Throws: Nothing.

Return Value

Class fd_deleter

POSIX-like file descriptor deleter

Synopsis

Declared in header <boost/scope/fd_deleter.hpp>

struct fd_deleter;

Types

Name

Description

result_type

Member Functions

Name

Description

operator()

Closes the file descriptor

fd_deleter::result_type

Synopsis

Declared in header <boost/scope/fd_deleter.hpp>

typedef void result_type;

Function fd_deleter::operator()

Closes the file descriptor

Synopsis

Declared in header <boost/scope/fd_deleter.hpp>

result_type
operator()(int fd) const noexcept;

Class fd_resource_traits

POSIX-like file descriptor resource traits

Synopsis

Declared in header <boost/scope/fd_resource_traits.hpp>

struct fd_resource_traits;

Static Member Functions

Name

Description

is_allocated

Tests if the fd is allocated (valid)

make_default

Creates a default fd value

Function fd_resource_traits::make_default

Creates a default fd value

Synopsis

Declared in header <boost/scope/fd_resource_traits.hpp>

static
int
make_default() noexcept;

Function fd_resource_traits::is_allocated

Tests if the fd is allocated (valid)

Synopsis

Declared in header <boost/scope/fd_resource_traits.hpp>

static
bool
is_allocated(int fd) noexcept;

Class scope_exit

Scope exit guard that conditionally invokes a function upon leaving the scope.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    typename Func,
    typename Cond = always_true>
class scope_exit;

Member Functions

Name

Description

active

Returns true if the scope guard is active, otherwise false.

operator=

release

Deactivates the scope guard.

scope_exit

set_active

Activates or deactivates the scope guard.

~scope_exit

If active() == true, and invoking the condition function object returns true, invokes the wrapped callable action function object. Destroys the function objects.

Description

The scope guard wraps two function objects: the scope guard action and a condition for invoking the action. Both function objects must be callable with no arguments and can be one of:

  • A user-defined class with a public operator().

  • An lvalue reference to such class.

  • An lvalue reference or pointer to function taking no arguments. The condition function object operator() must return a value contextually convertible to true, if the action function object is allowed to be executed, and false otherwise. Additionally, the condition function object operator() must not throw, as otherwise the action function object may not be called. The condition function object is optional, and if not specified in template parameters, the scope guard will operate as if the condition always returns true. The scope guard can be in either active or inactive state. By default, the constructed scope guard is active. When active, and condition function object returns true, the scope guard invokes the wrapped action function object on destruction. Otherwise, the scope guard does not call the wrapped action function object. The scope guard can be made inactive by moving-from the scope guard or calling set_active(false) or release(). An inactive scope guard can be made active by calling set_active(true). If a moved-from scope guard is active on destruction, the behavior is undefined.

Overload set scope_exit::scope_exit

Members

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_nothrow_default_constructible<Cond>, std::is_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>, detail::is_not_like_scope_exit<F>>::value>::type>
scope_exit(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>::value);
  » more...
template<
    typename F,
    typename C,
    typename = enable_if<detail::conjunction<detail::is_invocable<const C &>, std::is_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<C, Cond>::type, bool>>::value>::type>
scope_exit(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<C, Cond>::type, bool>::value);
  » more...
template<
    bool Requires = std::is_constructible<data, typename detail::move_or_copy_construct_ref<Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>::value,
    typename = enable_if<Requires>::type>
scope_exit(scope_exit&& that) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>::value);
  » more...
scope_exit(const scope_exit&) = delete;
  » more...

Overload set scope_exit::operator=

Members

scope_exit&
operator=(scope_exit&&) = delete;
  » more...
scope_exit&
operator=(const scope_exit&) = delete;
  » more...

Function scope_exit::~scope_exit

If active() == true, and invoking the condition function object returns true, invokes the wrapped callable action function object. Destroys the function objects.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

~scope_exit() noexcept(detail::conjunction<detail::is_nothrow_invocable<Func &>, detail::is_nothrow_invocable<Cond &>>::value);

Description

Throws: Nothing, unless invoking a function object throws.

Function scope_exit::active

Returns true if the scope guard is active, otherwise false.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

bool
active() const noexcept;

Description

Note
This method does not call the condition function object specified on construction. Throws: Nothing.

Return Value

  • bool

Function scope_exit::set_active

Activates or deactivates the scope guard.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

void
set_active(bool active) noexcept;

Description

Throws: Nothing.

Return Value

  • void

Parameters

Name Type

active

bool

Function scope_exit::release

Deactivates the scope guard.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

void
release() noexcept;

Description

Effects: As if set_active(false). Throws: Nothing.

Return Value

  • void

Class always_true

A predicate that always returns true.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

class always_true;

Types

Name

Description

result_type

Predicate result type

Member Functions

Name

Description

operator()

Throws: Nothing.

Description

This predicate can be used as the default condition function object for scope_exit and similar scope guards.

always_true::result_type

Predicate result type

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

typedef bool result_type;

Function always_true::operator()

Throws: Nothing.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

result_type
operator()() const noexcept;

Deduction guide scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<typename Func>
scope_exit<Func>(Func) -> scope_exit<Func>;

Deduction guide scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<typename Func>
scope_exit<Func>(
    Func,
    bool) -> scope_exit<Func>;

Deduction guide scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    typename Func,
    typename Cond>
scope_exit<Func, Cond>(
    Func,
    Cond) -> scope_exit<Func, Cond>;

Deduction guide scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    typename Func,
    typename Cond>
scope_exit<Func, Cond>(
    Func,
    Cond,
    bool) -> scope_exit<Func, Cond>;

Overload set make_scope_exit

Members

Creates a scope guard with a given action function object.

template<typename F>
scope_exit<decay<F>::type>
make_scope_exit(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_exit<typename std::decay<F>::type>, F, bool>::value);
  » more...
template<
    typename F,
    typename C>
enable_if<std::is_constructible<scope_exit<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value, scope_exit<decay<F>::type, decay<C>::type>>::type
make_scope_exit(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_exit<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value);
  » more...

Class scope_fail

Scope exit guard that invokes a function upon leaving the scope with a failure condition satisfied.

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    typename Func,
    typename Cond = exception_checker>
class scope_fail
    : public scope_exit<Func, Cond>;

Member Functions

Name

Description

active

Returns true if the scope guard is active, otherwise false.

operator=

release

Deactivates the scope guard.

scope_fail

set_active

Activates or deactivates the scope guard.

Description

The scope guard wraps two function objects: the scope guard action and a failure condition for invoking the action. Both function objects must be callable with no arguments and can be one of:

  • A user-defined class with a public operator().

  • An lvalue reference to such class.

  • An lvalue reference or pointer to function taking no arguments. The condition function object operator() must return a value contextually convertible to true, if the failure is detected and the action function object is allowed to be executed, and false otherwise. Additionally, the failure condition function object operator() must not throw, as otherwise the action function object may not be called. If not specified, the default failure condition checks whether the scope is left due to an exception - the action function object will not be called if the scope is left normally.

Overload set scope_fail::scope_fail

Members

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_constructible<base_type, F, bool>, detail::is_not_like_scope_fail<F>>::value>::type>
scope_fail(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, bool>::value);
  » more...
template<
    typename F,
    typename C,
    typename = enable_if<std::is_constructible<base_type, F, C, bool>::value>::type>
scope_fail(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, C, bool>::value);
  » more...
template<
    bool Requires = std::is_move_constructible<base_type>::value,
    typename = enable_if<Requires>::type>
scope_fail(scope_fail&& that) noexcept(std::is_nothrow_move_constructible<base_type>::value);
  » more...
scope_fail(const scope_fail&) = delete;
  » more...

Overload set scope_fail::operator=

Members

scope_fail&
operator=(scope_fail&&) = delete;
  » more...
scope_fail&
operator=(const scope_fail&) = delete;
  » more...

Deduction guide scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<typename Func>
scope_fail<Func>(Func) -> scope_fail<Func>;

Deduction guide scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<typename Func>
scope_fail<Func>(
    Func,
    bool) -> scope_fail<Func>;

Deduction guide scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    typename Func,
    typename Cond,
    typename = enable_if<detail::is_invocable<const Cond &>::value>::type>
scope_fail<Func, Cond>(
    Func,
    Cond) -> scope_fail<Func, Cond>;

Deduction guide scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    typename Func,
    typename Cond,
    typename = enable_if<detail::is_invocable<const Cond &>::value>::type>
scope_fail<Func, Cond>(
    Func,
    Cond,
    bool) -> scope_fail<Func, Cond>;

Overload set make_scope_fail

Members

Creates a scope fail guard with a given action function object.

template<typename F>
scope_fail<decay<F>::type>
make_scope_fail(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_fail<typename std::decay<F>::type>, F, bool>::value);
  » more...
template<
    typename F,
    typename C>
enable_if<detail::is_invocable<const C &>::value, scope_fail<decay<F>::type, decay<C>::type>>::type
make_scope_fail(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_fail<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value);
  » more...

Class scope_final

Scope final guard that invokes a function upon leaving the scope.

Synopsis

Declared in header <boost/scope/scope_final.hpp>

template<typename Func>
class scope_final;

Member Functions

Name

Description

operator=

scope_final

~scope_final

Invokes the wrapped callable function object and destroys the callable.

Description

The scope guard wraps a function object callable with no arguments that can be one of:

  • A user-defined class with a public operator().

  • An lvalue reference to such class.

  • An lvalue reference or pointer to function taking no arguments. The scope final guard unconditionally invokes the wrapped function object on destruction.

Overload set scope_final::scope_final

Members

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename std::is_nothrow_constructible<Func, typename detail::move_or_copy_construct_ref<F, Func>::type>::type>, detail::is_not_like_scope_final<F>>::value>::type>
scope_final(F&& func) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename std::is_nothrow_constructible<Func, typename detail::move_or_copy_construct_ref<F, Func>::type>::type>::value);
  » more...
scope_final(const scope_final&) = delete;
  » more...

Function scope_final::operator=

Synopsis

Declared in header <boost/scope/scope_final.hpp>

scope_final&
operator=(const scope_final&) = delete;

Function scope_final::~scope_final

Invokes the wrapped callable function object and destroys the callable.

Synopsis

Declared in header <boost/scope/scope_final.hpp>

~scope_final() noexcept(detail::is_nothrow_invocable<Func &>::value);

Description

Throws: Nothing, unless invoking the callable throws.

Deduction guide scope_final

Synopsis

Declared in header <boost/scope/scope_final.hpp>

template<typename Func>
scope_final<Func>(Func) -> scope_final<Func>;

Class scope_success

Scope exit guard that invokes a function upon leaving the scope with a failure condition not satisfied.

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    typename Func,
    typename Cond = exception_checker>
class scope_success
    : public scope_exit<Func, logical_not<Cond>>;

Member Functions

Name

Description

active

Returns true if the scope guard is active, otherwise false.

operator=

release

Deactivates the scope guard.

scope_success

set_active

Activates or deactivates the scope guard.

Description

The scope guard wraps two function objects: the scope guard action and a failure condition for invoking the action. Both function objects must be callable with no arguments and can be one of:

  • A user-defined class with a public operator().

  • An lvalue reference to such class.

  • An lvalue reference or pointer to function taking no arguments. The condition function object operator() must return a value contextually convertible to true, if the failure is detected and the action function object is not allowed to be executed, and false otherwise. Additionally, the failure condition function object operator() must not throw, as otherwise the action function object may not be called. If not specified, the default failure condition checks whether the scope is left due to an exception - the action function object will only be called if the scope is left normally.

Overload set scope_success::scope_success

Members

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_constructible<base_type, F, bool>, detail::is_not_like_scope_success<F>>::value>::type>
scope_success(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, bool>::value);
  » more...
template<
    typename F,
    typename C,
    typename = enable_if<std::is_constructible<base_type, F, C, bool>::value>::type>
scope_success(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, C, bool>::value);
  » more...
template<
    bool Requires = std::is_move_constructible<base_type>::value,
    typename = enable_if<Requires>::type>
scope_success(scope_success&& that) noexcept(std::is_nothrow_move_constructible<base_type>::value);
  » more...
scope_success(const scope_success&) = delete;
  » more...

Overload set scope_success::operator=

Members

scope_success&
operator=(scope_success&&) = delete;
  » more...
scope_success&
operator=(const scope_success&) = delete;
  » more...

Deduction guide scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<typename Func>
scope_success<Func>(Func) -> scope_success<Func>;

Deduction guide scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<typename Func>
scope_success<Func>(
    Func,
    bool) -> scope_success<Func>;

Deduction guide scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    typename Func,
    typename Cond,
    typename = enable_if<detail::is_invocable<const Cond &>::value>::type>
scope_success<Func, Cond>(
    Func,
    Cond) -> scope_success<Func, Cond>;

Deduction guide scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    typename Func,
    typename Cond,
    typename = enable_if<detail::is_invocable<const Cond &>::value>::type>
scope_success<Func, Cond>(
    Func,
    Cond,
    bool) -> scope_success<Func, Cond>;

Overload set make_scope_success

Members

Creates a scope fail guard with a given action function object.

template<typename F>
scope_success<decay<F>::type>
make_scope_success(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_success<typename std::decay<F>::type>, F, bool>::value);
  » more...
template<
    typename F,
    typename C>
enable_if<detail::is_invocable<const C &>::value, scope_success<decay<F>::type, decay<C>::type>>::type
make_scope_success(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_success<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value);
  » more...

Class unique_resource

RAII wrapper for automatically reclaiming arbitrary resources.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    typename Resource,
    typename Deleter,
    typename Traits = void>
class unique_resource;

Types

Name

Description

deleter_type

Deleter type

resource_type

Resource type

traits_type

Resource traits

Member Functions

Name

Description

allocated

Returns true if the resource is allocated and to be reclaimed by the deleter, otherwise false.

get

Returns a reference to the resource object.

get_deleter

Returns a reference to the deleter object.

operator*

operator->

operator=

release

Marks the resource as unallocated. Does not call the deleter if the resource was previously allocated.

reset

If the resource is allocated, calls the deleter function on it and marks the resource as unallocated.

swap

unique_resource

~unique_resource

Invokes reset() and destroys the resource.

Friends

Name

Description

swap

Description

A unique_resource object exclusively owns wrapped resource and invokes the deleter function object on it on destruction. The wrapped resource can have any type that is:

  • Move-constructible, where the move constructor is marked as noexcept, or

  • Copy-constructible, or

  • An lvalue reference to an object type. The deleter must be a function object type that is callable on an lvalue of the resource type. The deleter must be copy-constructible. An optional resource traits template parameter may be specified. Resource traits can be used to optimize unique_resource implementation when the following conditions are met:

  • There is at least one value of the resource type that is considered unallocated (that is, no allocated resource shall be equal to one of the unallocated resource values). The unallocated resource values need not be deallocated using the deleter.

  • One of the unallocated resource values can be considered the default. Constructing the default resource value and assigning it to a resource object (whether allocated or not) shall not throw exceptions.

  • Resource objects can be tested for being unallocated. Such a test shall not throw exceptions. If specified, the resource traits must be a class that has the following public static members:

  • Resource make_default() noexcept - must return the default resource value.

  • `bool is_allocated(Resource const & res) noexcept` - must return true if res is not one of the unallocated resource values and false otherwise. Note that is_allocated(make_default()) must always return false. When conforming resource traits are specified, unique_resource will be able to avoid storing additional indication of whether the owned resource object needs to be deallocated with the deleter on destruction. It will use the default resource value to initialize the owned resource object when unique_resource is not in the allocated state. Additionally, it will be possible to construct unique_resource with unallocated resource values, which will create unique_resource objects in deallocated state (the deleter will not be called on unallocated resource values).

unique_resource::resource_type

Resource type

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

typedef Resource resource_type;

unique_resource::deleter_type

Deleter type

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

typedef Deleter deleter_type;

unique_resource::traits_type

Resource traits

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

typedef Traits traits_type;

Overload set unique_resource::unique_resource

Members

template<
    bool Requires = std::is_default_constructible<data>::value,
    typename = enable_if<Requires>::type>
constexpr
unique_resource() noexcept(std::is_nothrow_default_constructible<data>::value);
  » more...
template<
    typename D,
    typename = enable_if<std::is_constructible<data, default_resource_t, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>::value>::type>
unique_resource(
    default_resource_t res,
    D&& del) noexcept(std::is_nothrow_constructible<data, default_resource_t, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>::value);
  » more...
template<
    typename R,
    typename = enable_if<detail::conjunction<std::is_nothrow_default_constructible<deleter_type>, std::is_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<deleter_type>::type>, detail::disjunction<detail::negation<std::is_reference<resource_type>>, std::is_reference<R>>>::value>::type>
unique_resource(R&& res) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<deleter_type>::type>::value);
  » more...
template<
    typename R,
    typename D,
    typename = enable_if<detail::conjunction<std::is_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>, detail::disjunction<detail::negation<std::is_reference<resource_type>>, std::is_reference<R>>>::value>::type>
unique_resource(
    R&& res,
    D&& del) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>::value);
  » more...
unique_resource(const unique_resource&) = delete;
  » more...
template<
    bool Requires = std::is_move_constructible<data>::value,
    typename = enable_if<Requires>::type>
unique_resource(unique_resource&& that) noexcept(std::is_nothrow_move_constructible<data>::value);
  » more...

Overload set unique_resource::operator=

Members

unique_resource&
operator=(const unique_resource&) = delete;
  » more...
template<bool Requires = std::is_move_assignable<data>::value>
enable_if<Requires, unique_resource&>::type
operator=(unique_resource&& that) noexcept(std::is_nothrow_move_assignable<data>::value);
  » more...

Function unique_resource::~unique_resource

Invokes reset() and destroys the resource.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

~unique_resource() noexcept(detail::is_nothrow_invocable<deleter_type &, resource_type &>::value);

Description

Throws: Nothing, unless invoking the deleter throws.

Function unique_resource::allocated

Returns true if the resource is allocated and to be reclaimed by the deleter, otherwise false.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

bool
allocated() const noexcept;

Description

Throws: Nothing.

Return Value

  • bool

Function unique_resource::get

Returns a reference to the resource object.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

const resource_type&
get() const noexcept;

Description

Throws: Nothing.

Return Value

Function unique_resource::get_deleter

Returns a reference to the deleter object.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

const deleter_type&
get_deleter() const noexcept;

Description

Throws: Nothing.

Return Value

Function unique_resource::release

Marks the resource as unallocated. Does not call the deleter if the resource was previously allocated.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

void
release() noexcept;

Description

Throws: Nothing.

Return Value

  • void

Overload set unique_resource::reset

Members

If the resource is allocated, calls the deleter function on it and marks the resource as unallocated.

void
reset() noexcept(detail::is_nothrow_invocable<deleter_type &, resource_type &>::value);
  » more...
template<typename R>
enable_if<detail::conjunction<std::is_assignable<internal_resource_type &, typename detail::move_or_copy_assign_ref<R, resource_type>::type>, detail::disjunction<detail::negation<std::is_reference<resource_type>>, std::is_reference<R>>>::value>::type
reset(R&& res) noexcept(detail::conjunction<detail::is_nothrow_invocable<deleter_type &, resource_type &>, std::is_nothrow_assignable<internal_resource_type &, typename detail::move_or_copy_assign_ref<R, resource_type>::type>>::value);
  » more...

Function unique_resource::operator→

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<bool Requires = detail::is_dereferenceable<resource_type>::value>
enable_if<Requires, const resource_type&>::type
operator->() const noexcept;

Function unique_resource::operator*

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<bool Requires = detail::is_dereferenceable<resource_type>::value>
dereference_traits<resource_type, Requires>::result_type
operator*() const noexcept(detail::dereference_traits<resource_type, Requires>::is_noexcept);

Function unique_resource::swap

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<bool Requires = detail::is_swappable<data>::value>
enable_if<Requires>::type
swap(unique_resource& that) noexcept(detail::is_nothrow_swappable<data>::value);

Friend swap

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<bool Requires = detail::is_swappable<data>::value>
friend
enable_if<Requires>::type
swap(
    unique_resource& left,
    unique_resource& right) noexcept(detail::is_nothrow_swappable<data>::value);

Function make_unique_resource_checked

Checks if the resource is valid and creates a unique_resource wrapper.

Synopsis

template<
    typename Resource,
    typename Deleter,
    typename Invalid = decay<Resource>::type>
unique_resource<decay<Resource>::type, decay<Deleter>::type>
make_unique_resource_checked(
    Resource&& res,
    const Invalid& invalid,
    Deleter&& del) noexcept(detail::conjunction<std::is_nothrow_constructible<typename std::decay<Resource>::type, typename detail::move_or_copy_construct_ref<Resource, typename std::decay<Resource>::type>::type>, std::is_nothrow_constructible<typename std::decay<Deleter>::type, typename detail::move_or_copy_construct_ref<Deleter, typename std::decay<Deleter>::type>::type>>::value);

Description

Effects: If the resource res is not equal to invalid, creates a unique resource wrapper that is in allocated state and owns res. Otherwise creates a unique resource wrapper in deallocated state.

Note
This function does not call del if res is equal to invalid. Throws: Nothing, unless unique_resource constructor throws.

Return Value

Parameters

Name Type

res

Resource&&

invalid

const Invalid&

del

Deleter&&

Class default_resource_t

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

struct default_resource_t;

default_resource

Keyword representing default, unallocated resource argument

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

constexpr
const default_resource_t default_resource;

Function swap

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<bool Requires = detail::is_swappable<data>::value>
enable_if<Requires>::type
swap(
    unique_resource& left,
    unique_resource& right) noexcept(detail::is_nothrow_swappable<data>::value);

Deduction guide unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    typename Resource,
    typename Deleter,
    typename = enable_if<!detail::is_default_resource<Resource>::value>::type>
unique_resource<Resource, Deleter>(
    Resource,
    Deleter) -> unique_resource<Resource, Deleter>;

unique_fd

Unique POSIX-like file descriptor resource

Synopsis

Declared in header <boost/scope/unique_fd.hpp>

typedef unique_resource<int, fd_deleter, fd_resource_traits> unique_fd;

Function scope_exit::operator=

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

scope_exit&
operator=(scope_exit&&) = delete;

Function scope_exit::operator=

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

scope_exit&
operator=(const scope_exit&) = delete;

Function scope_fail::operator=

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

scope_fail&
operator=(scope_fail&&) = delete;

Function scope_fail::operator=

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

scope_fail&
operator=(const scope_fail&) = delete;

Function scope_exit::scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_nothrow_default_constructible<Cond>, std::is_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>, detail::is_not_like_scope_exit<F>>::value>::type>
scope_exit(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>::value);

Function scope_exit::scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    typename F,
    typename C,
    typename = enable_if<detail::conjunction<detail::is_invocable<const C &>, std::is_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<C, Cond>::type, bool>>::value>::type>
scope_exit(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename detail::move_or_copy_construct_ref<C, Cond>::type, bool>::value);

Function scope_exit::scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    bool Requires = std::is_constructible<data, typename detail::move_or_copy_construct_ref<Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>::value,
    typename = enable_if<Requires>::type>
scope_exit(scope_exit&& that) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<Func>::type, typename detail::move_or_copy_construct_ref<Cond>::type, bool>::value);

Function scope_exit::scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

scope_exit(const scope_exit&) = delete;

Function scope_final::scope_final

Synopsis

Declared in header <boost/scope/scope_final.hpp>

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename std::is_nothrow_constructible<Func, typename detail::move_or_copy_construct_ref<F, Func>::type>::type>, detail::is_not_like_scope_final<F>>::value>::type>
scope_final(F&& func) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<F, Func>::type, typename std::is_nothrow_constructible<Func, typename detail::move_or_copy_construct_ref<F, Func>::type>::type>::value);

Function scope_final::scope_final

Synopsis

Declared in header <boost/scope/scope_final.hpp>

scope_final(const scope_final&) = delete;

Function make_scope_exit

Creates a scope guard with a given action function object.

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<typename F>
scope_exit<decay<F>::type>
make_scope_exit(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_exit<typename std::decay<F>::type>, F, bool>::value);

Description

Effects: Constructs a scope guard as if by calling `scope_exit < std::decay_t < F > >(std::forward < F >(func), active)`.

Return Value

Parameters

Name Type

func

F&&

active

bool

Function make_scope_exit

Synopsis

Declared in header <boost/scope/scope_exit.hpp>

template<
    typename F,
    typename C>
enable_if<std::is_constructible<scope_exit<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value, scope_exit<decay<F>::type, decay<C>::type>>::type
make_scope_exit(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_exit<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value);

Function scope_fail::scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_constructible<base_type, F, bool>, detail::is_not_like_scope_fail<F>>::value>::type>
scope_fail(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, bool>::value);

Function scope_fail::scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    typename F,
    typename C,
    typename = enable_if<std::is_constructible<base_type, F, C, bool>::value>::type>
scope_fail(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, C, bool>::value);

Function scope_fail::scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    bool Requires = std::is_move_constructible<base_type>::value,
    typename = enable_if<Requires>::type>
scope_fail(scope_fail&& that) noexcept(std::is_nothrow_move_constructible<base_type>::value);

Function scope_fail::scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

scope_fail(const scope_fail&) = delete;

Function scope_success::operator=

Synopsis

Declared in header <boost/scope/scope_success.hpp>

scope_success&
operator=(scope_success&&) = delete;

Function scope_success::operator=

Synopsis

Declared in header <boost/scope/scope_success.hpp>

scope_success&
operator=(const scope_success&) = delete;

Function make_scope_fail

Creates a scope fail guard with a given action function object.

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<typename F>
scope_fail<decay<F>::type>
make_scope_fail(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_fail<typename std::decay<F>::type>, F, bool>::value);

Description

Effects: Constructs a scope guard as if by calling `scope_fail < std::decay_t < F > >(std::forward < F >(func), active)`.

Return Value

Parameters

Name Type

func

F&&

active

bool

Function make_scope_fail

Synopsis

Declared in header <boost/scope/scope_fail.hpp>

template<
    typename F,
    typename C>
enable_if<detail::is_invocable<const C &>::value, scope_fail<decay<F>::type, decay<C>::type>>::type
make_scope_fail(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_fail<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value);

Function unique_resource::reset

If the resource is allocated, calls the deleter function on it and marks the resource as unallocated.

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

void
reset() noexcept(detail::is_nothrow_invocable<deleter_type &, resource_type &>::value);

Description

Throws: Nothing, unless invoking the deleter throws.

Return Value

  • void

Function unique_resource::reset

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<typename R>
enable_if<detail::conjunction<std::is_assignable<internal_resource_type &, typename detail::move_or_copy_assign_ref<R, resource_type>::type>, detail::disjunction<detail::negation<std::is_reference<resource_type>>, std::is_reference<R>>>::value>::type
reset(R&& res) noexcept(detail::conjunction<detail::is_nothrow_invocable<deleter_type &, resource_type &>, std::is_nothrow_assignable<internal_resource_type &, typename detail::move_or_copy_assign_ref<R, resource_type>::type>>::value);

Function unique_resource::operator=

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

unique_resource&
operator=(const unique_resource&) = delete;

Function unique_resource::operator=

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<bool Requires = std::is_move_assignable<data>::value>
enable_if<Requires, unique_resource&>::type
operator=(unique_resource&& that) noexcept(std::is_nothrow_move_assignable<data>::value);

Function scope_success::scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    typename F,
    typename = enable_if<detail::conjunction<std::is_constructible<base_type, F, bool>, detail::is_not_like_scope_success<F>>::value>::type>
scope_success(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, bool>::value);

Function scope_success::scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    typename F,
    typename C,
    typename = enable_if<std::is_constructible<base_type, F, C, bool>::value>::type>
scope_success(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<base_type, F, C, bool>::value);

Function scope_success::scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    bool Requires = std::is_move_constructible<base_type>::value,
    typename = enable_if<Requires>::type>
scope_success(scope_success&& that) noexcept(std::is_nothrow_move_constructible<base_type>::value);

Function scope_success::scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

scope_success(const scope_success&) = delete;

Function make_scope_success

Creates a scope fail guard with a given action function object.

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<typename F>
scope_success<decay<F>::type>
make_scope_success(
    F&& func,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_success<typename std::decay<F>::type>, F, bool>::value);

Description

Effects: Constructs a scope guard as if by calling `scope_success < std::decay_t < F > >(std::forward < F >(func), active)`.

Return Value

Parameters

Name Type

func

F&&

active

bool

Function make_scope_success

Synopsis

Declared in header <boost/scope/scope_success.hpp>

template<
    typename F,
    typename C>
enable_if<detail::is_invocable<const C &>::value, scope_success<decay<F>::type, decay<C>::type>>::type
make_scope_success(
    F&& func,
    C&& cond,
    bool active = true) noexcept(std::is_nothrow_constructible<scope_success<typename std::decay<F>::type, typename std::decay<C>::type>, F, C, bool>::value);

Function unique_resource::unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    bool Requires = std::is_default_constructible<data>::value,
    typename = enable_if<Requires>::type>
constexpr
unique_resource() noexcept(std::is_nothrow_default_constructible<data>::value);

Function unique_resource::unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    typename D,
    typename = enable_if<std::is_constructible<data, default_resource_t, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>::value>::type>
unique_resource(
    default_resource_t res,
    D&& del) noexcept(std::is_nothrow_constructible<data, default_resource_t, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>::value);

Function unique_resource::unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    typename R,
    typename = enable_if<detail::conjunction<std::is_nothrow_default_constructible<deleter_type>, std::is_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<deleter_type>::type>, detail::disjunction<detail::negation<std::is_reference<resource_type>>, std::is_reference<R>>>::value>::type>
unique_resource(R&& res) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<deleter_type>::type>::value);

Function unique_resource::unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    typename R,
    typename D,
    typename = enable_if<detail::conjunction<std::is_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>, detail::disjunction<detail::negation<std::is_reference<resource_type>>, std::is_reference<R>>>::value>::type>
unique_resource(
    R&& res,
    D&& del) noexcept(std::is_nothrow_constructible<data, typename detail::move_or_copy_construct_ref<R, resource_type>::type, typename detail::move_or_copy_construct_ref<D, deleter_type>::type>::value);

Function unique_resource::unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

unique_resource(const unique_resource&) = delete;

Function unique_resource::unique_resource

Synopsis

Declared in header <boost/scope/unique_resource.hpp>

template<
    bool Requires = std::is_move_constructible<data>::value,
    typename = enable_if<Requires>::type>
unique_resource(unique_resource&& that) noexcept(std::is_nothrow_move_constructible<data>::value);

Created with MrDocs