#include <userver/utils/any_movable.hpp>
Replacement for std::any
that is not copyable. It allows to store non-copyable and even non-movable types.
Usage example:
Definition at line 24 of file any_movable.hpp.
Classes | |
struct | HolderBase |
Public Member Functions | |
constexpr | AnyMovable () noexcept=default |
Creates an empty AnyMovable | |
AnyMovable (AnyMovable &&) noexcept=default | |
AnyMovable is movable, but not copyable | |
AnyMovable & | operator= (AnyMovable &&) noexcept=default |
template<typename ValueType , typename = std::enable_if_t<!std::is_same_v< AnyMovable, std::decay_t<ValueType>>>> | |
AnyMovable (ValueType &&value) | |
template<typename ValueType , typename... Args> | |
AnyMovable (std::in_place_type_t< ValueType > tag, Args &&... args) | |
In-place constructs an object of the specified type. | |
template<typename ValueType , typename Item , typename... Args> | |
AnyMovable (std::in_place_type_t< ValueType > tag, std::initializer_list< Item > list, Args &&... args) | |
In-place constructs an object of the specified type. | |
template<typename ValueType > | |
AnyMovable & | operator= (ValueType &&rhs) |
bool | HasValue () const noexcept |
Check if the AnyMovable is empty. | |
void | Reset () noexcept |
Destroy the old contents, making *this empty. | |
template<typename ValueType , typename... Args> | |
ValueType & | Emplace (Args &&... args) |
In-place constructs an object of the specified type. | |
template<typename ValueType , typename Item , typename... Args> | |
ValueType & | Emplace (std::initializer_list< Item > list, Args &&... args) |
In-place constructs an object of the specified type. | |
Copies or moves the provided object inside the AnyMovable
. const
, reference, arrays and function pointers are decayed.
Definition at line 153 of file any_movable.hpp.
|
explicit |
In-place constructs an object of the specified type.
Definition at line 164 of file any_movable.hpp.
|
explicit |
In-place constructs an object of the specified type.
Definition at line 168 of file any_movable.hpp.
ValueType & utils::AnyMovable::Emplace | ( | Args &&... | args | ) |
In-place constructs an object of the specified type.
Definition at line 179 of file any_movable.hpp.
ValueType & utils::AnyMovable::Emplace | ( | std::initializer_list< Item > | list, |
Args &&... | args ) |
In-place constructs an object of the specified type.
Definition at line 185 of file any_movable.hpp.
AnyMovable & utils::AnyMovable::operator= | ( | ValueType && | rhs | ) |
Copies or moves the provided object inside the AnyMovable
. const
, reference, arrays and function pointers are decayed.
Definition at line 173 of file any_movable.hpp.
|
friend |
Definition at line 192 of file any_movable.hpp.
|
friend |
Definition at line 197 of file any_movable.hpp.