kblib 0.2.3
General utilities library for modern C++
|
Provides utilities for working with std::variant more expressively and more efficiently. More...
#include "convert.h"
#include "logic.h"
#include "tdecl.h"
#include <cstddef>
#include <new>
#include <variant>
Go to the source code of this file.
Classes | |
struct | kblib::is_variant_like< T > |
struct | kblib::visitor< Ts > |
Helper class for std::visiting a std::variant. More... | |
struct | kblib::detail::tuple_type< T > |
Given a std::variant T, provides the member type which is a tuple of the same types. More... | |
struct | kblib::detail::tuple_type< std::variant< Ts... > > |
Given a std::variant T, provides the member type which is a tuple of the same types. More... | |
Namespaces | |
namespace | kblib |
The main namespace in which all entities from kblib are defined. | |
namespace | kblib::detail |
The namespace used for implementation details within kblib. | |
namespace | kblib::literals |
Typedefs | |
template<typename T > | |
using | kblib::detail::tuple_type_t = typename tuple_type< T >::type |
Functions | |
template<typename To , typename... Ts> | |
auto | kblib::coerce (const std::variant< Ts... > &v) -> To |
Lexically converts the value of v (no matter its type) to type To. More... | |
template<typename To , typename... Ts> | |
auto | kblib::static_coerce (const std::variant< Ts... > &v) -> To |
static_casts the value of v (no matter its type) to type To. More... | |
template<typename To , typename... Ts> | |
auto | kblib::lexical_coerce (const std::variant< Ts... > &v) -> To |
Lexically converts the value of v (no matter its type) to type To. More... | |
template<typename... Ts> | |
kblib::visitor (Ts...) -> visitor< Ts... > | |
template<typename Variant , typename F , std::size_t... Is> | |
constexpr auto | kblib::detail::indexed_visitor_impl (std::index_sequence< Is... >) -> auto |
Generates an array of function pointers which will unwrap the variant and pass the index to the function. More... | |
template<char... Cs> | |
constexpr auto | kblib::literals::operator""_vi () |
template<typename Variant , typename... Fs> | |
constexpr auto | kblib::visit_indexed (Variant &&variant, Fs &&... fs) -> decltype(auto) |
Visit a variant, but pass the index (as an integral_constant) to the visitor. This allows for a visitor of a variant with duplicated types to maintain index information. More... | |
template<typename To , typename From > | |
constexpr auto | kblib::variant_cast (From &&v) -> To |
Promotes an input variant to a super-variant. That is, one which provides at least the same set of types. More... | |
template<typename V , typename F , typename... Fs> | |
constexpr auto | kblib::visit (V &&v, F &&f, Fs &&... fs) -> decltype(auto) |
Wraps std::visit to provide an interface taking one variant and any number of functors providing an overload set. More... | |
template<typename V , typename F , std::size_t I, std::size_t... Is> | |
constexpr decltype(auto) | kblib::detail::visit_impl (V &&v, F &&f, std::index_sequence< I, Is... >) |
template<typename V , typename F , std::size_t I, std::size_t... Is> | |
constexpr void | kblib::detail::visit_nop_impl (V &&v, F &&f, std::index_sequence< I, Is... >) |
template<typename V , typename F , typename... Fs> | |
constexpr auto | kblib::visit2 (V &&v, F &&f, Fs &&... fs) -> decltype(auto) |
template<typename V , typename F , typename... Fs> | |
constexpr auto | kblib::visit2_nop (V &&v, F &&f, Fs &&... fs) -> void |
template<typename V > | |
constexpr auto | kblib::visit (V &v) -> auto |
Two-step visiting interface. Takes a variant, and returns an object which can be called with any number of callable arguments, builds an overload set from them, and visits the variant. More... | |
Variables | |
template<typename T , typename = void> | |
constexpr bool | kblib::is_variant_like_v = false |
template<typename F , typename... Ts> | |
constexpr bool | kblib::detail::invocable_with_all_v = (ignore_t<std::invoke_result_t<F, Ts>, std::true_type>::value and ...) |
template<typename Callable , typename Variant > | |
constexpr bool | kblib::detail::v_invocable_with_all_v = false |
Provides utilities for working with std::variant more expressively and more efficiently.
Definition in file variant.h.