Any++
Loading...
Searching...
No Matches
Proxies

Proxies manage the storage in an any. More...

Classes

struct  anyxx::unique
union  anyxx::val
 Proxy to manage the captured object as value with small object optimization. More...

Typedefs

template<template< typename > typename Any, is_proxy Proxy, typename... Types>
using anyxx::vany_variant = std::variant<Any<Proxy>, Types...>
using anyxx::cref = observer<const_void>
using anyxx::mutref = observer<mutable_void>
using anyxx::shared = std::shared_ptr<void const>
using anyxx::weak = std::weak_ptr<void const>

Detailed Description

Proxies manage the storage in an any.

Typedef Documentation

◆ cref

using anyxx::cref = observer<const_void>

Proxy to capture the dispatch target type erased by const reference An any with such a proxy is lifetime bound to the object referenced!

Examples
_2b_trait_monoid.cpp, _3_any_range.cpp, and _5_any_template.cpp.

◆ mutref

using anyxx::mutref = observer<mutable_void>

Proxy to capture the dispatch target type erased by mutable reference An any with such a proxy is lifetime bound to the object referenced!

Examples
_5_any_template.cpp.

◆ shared

using anyxx::shared = std::shared_ptr<void const>

Proxy to manage the captured object via std::shared_ptr.

  • If you pass a std::shared_ptr to the any constructor, this pointer will be casted to <const void*> and used as proxy.
  • If you pass an object as second parameter, with the std::in_place tag as first, this object will be forwarded to std::make_shared with the decayed type of object.
  • If you pass as first parameter std::in_place_type<T>, the other arguments will be forwarded to std::make_shared<T>(...).
Examples
21_Tree_any.cpp, and 21_Tree_any_dispatch.cpp.

◆ vany_variant

template<template< typename > typename Any, is_proxy Proxy, typename... Types>
using anyxx::vany_variant = std::variant<Any<Proxy>, Types...>

A Proxy for mixing std::variant and type erasure Use this when some, at compile time, known types are dispatched in a hot path. Put these types plus an any (with the specific trait and a dynamic proxy) in a std::variant. This variant is then used with a using_ proxy and the same trait as before. See make_vany So the dispatch for the types in the variant is done internally with a std::visit, and all other types are dispatched via their v-Table. Now you know where the Any++ logo has its origin.

Examples
_2c_trait_any_variant.cpp.

◆ weak

using anyxx::weak = std::weak_ptr<void const>

Proxy to manage the captured object via std::weak_ptr. Assign or copy construct it from a any<shared>