|
DocWire SDK
DocWire SDK: Award-winning modern data processing in C++20. SourceForge Community Choice & Microsoft support. AI-driven processing. Supports nearly 100 data formats, including email boxes and OCR. Boost efficiency in text extraction, web data extraction, data mining, document analysis. Offline processing possible for security and confidentiality
|
A generic wrapper for dereferenceable types (like pointers and optionals) that provides checked access based on a safety_policy. More...
#include <checked.h>
Public Member Functions | |
| checked ()=default | |
| Default constructor. | |
| checked (const Dereferenceable &value) | |
| Constructs from a value. Implicit conversion is allowed to support seamless wrapping of null-like types. | |
| checked (Dereferenceable &&value) noexcept(std::is_nothrow_move_constructible_v< Dereferenceable >) | |
| Move-constructs from a value. | |
| template<typename... Args, typename = std::enable_if_t< std::is_constructible_v<Dereferenceable, Args...> && (sizeof...(Args) > 1 || (sizeof...(Args) == 1 && ((!std::is_same_v<std::decay_t<Args>, checked> && !std::is_same_v<std::decay_t<Args>, Dereferenceable>) && ...))) >> | |
| checked (Args &&... args) | |
| Forwards arguments to construct the underlying object in-place. | |
| checked & | operator= (const Dereferenceable &value) |
| checked & | operator= (Dereferenceable &&value) noexcept(std::is_nothrow_move_assignable_v< Dereferenceable >) |
| const auto & | operator* () const |
| Returns a reference to the underlying value, checking for validity in strict mode. | |
| auto & | operator* () |
| Returns a reference to the underlying value, checking for validity in strict mode. | |
| auto | operator-> () const |
| Returns a pointer to the underlying value, checking for validity in strict mode. | |
| operator bool () const noexcept | |
| Checks if the underlying value is valid (not null/empty). | |
| auto | get () const requires requires(const Dereferenceable &v) |
| Returns the raw underlying pointer/value without checks. | |
| bool | has_value () const noexcept(noexcept(std::declval< const Dereferenceable & >().has_value())) requires requires(const Dereferenceable &v) |
| Checks if the underlying object has a value. | |
| constexpr decltype(auto) | value () const noexcept(noexcept(std::declval< const Dereferenceable & >().value())) requires requires(const Dereferenceable &v) |
| Returns the value, potentially throwing if empty (forwarding underlying behavior). | |
| constexpr decltype(auto) | value () noexcept(noexcept(std::declval< Dereferenceable & >().value())) requires requires(Dereferenceable &v) |
| Returns the value, potentially throwing if empty (forwarding underlying behavior). | |
| template<typename U > | |
| constexpr auto | value_or (U &&default_value) const noexcept(noexcept(std::declval< const Dereferenceable & >().value_or(std::forward< U >(default_value)))) requires requires(const Dereferenceable &v) |
| Returns the contained value or a default value if empty. | |
| template<typename... Args> | |
| void | reset (Args &&... args) noexcept(noexcept(std::declval< Dereferenceable & >().reset(std::forward< Args >(args)...))) requires requires(Dereferenceable &v |
| Resets the underlying value. | |
| template<class... Args> | |
| auto & | emplace (Args &&... args) requires requires(Dereferenceable &v |
| Constructs the underlying value in-place. | |
| constexpr const Dereferenceable & | unwrap () const &noexcept |
| Unwraps the checked wrapper to return the underlying object. | |
| constexpr Dereferenceable & | unwrap () &noexcept |
| constexpr Dereferenceable && | unwrap () &&noexcept |
| constexpr | operator const Dereferenceable & () const &noexcept |
| constexpr | operator Dereferenceable & () &noexcept |
| constexpr | operator Dereferenceable && () &&noexcept |
Public Attributes | |
| void Args && | a { v.reset(std::forward<Args>(a)...) |
| auto Args && | a { v.emplace(std::forward<Args>(a)...) |
Friends | |
| template<typename U > | |
| constexpr friend bool | operator== (const checked &lhs, const U &rhs) requires(!std |
| Compares the underlying value with another value. | |
| constexpr friend bool | operator== (const checked &lhs, const checked &rhs) requires requires |
| Compares the underlying values of two checked wrappers. | |
A generic wrapper for dereferenceable types (like pointers and optionals) that provides checked access based on a safety_policy.
In strict mode, the dereference operators (*, ->) check if the object is valid and throw an exception if it does not. In relaxed mode, this wrapper is a zero-cost abstraction with no runtime checks, behaving like the underlying type.
| Dereferenceable | The underlying type (e.g., pointer, std::optional). |
| safety_level | The safety policy to apply. |