Iros
 
Loading...
Searching...
No Matches
di::util Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  AddMemberGet
 
class  Badge
 
class  DeferConstruct
 
struct  GetInPlaceFunction
 
class  GuardedReference
 
struct  Immovable
 
class  MovableBox
 
class  NamedArgument
 A helper class to simulate a single named argument. More...
 
class  NamedArguments
 A helper class for simulation named arguments in c++. More...
 
struct  NonCopyable
 
class  NonPropagatingCache
 
struct  OwnedType
 
class  RebindableBox
 
class  ReferenceWrapper
 
class  ScopeExit
 
class  ScopeValueChange
 
struct  SelfPointer
 
class  SourceLocation
 
struct  StoreIf
 
struct  StoreIf< T, false >
 
class  StrongInt
 
struct  SwapFunction
 
class  UUID
 

Functions

template<typename T>
constexpr auto as_const_pointer (T const *pointer)
 
template<concepts::CopyConstructible T>
auto black_box (T const &value) -> T
 
template<auto... values>
void compile_time_fail ()
 
constexpr void compiler_barrier ()
 Force to optimizer to reload memory addresses.
 
template<typename T, typename... Args>
requires (concepts::LanguageVoid<T> || concepts::CreatableFrom<T, Args...>)
constexpr auto create (Args &&... args)
 
template<template< typename... > typename Template, typename... Args>
requires (concepts::TemplateCreatableFrom<Template, Args...>)
constexpr auto create (Args &&... args)
 
template<typename T>
auto declval () -> meta::AddRValueReference< T >
 
template<typename T>
 DeferConstruct (T) -> DeferConstruct< T >
 
template<typename T, typename U = T>
constexpr auto exchange (T &object, U &&new_value) -> T
 
template<typename Derived, typename Base>
requires (concepts::DerivedFrom<meta::RemoveCVRef<Derived>, Base>)
constexpr auto forward_as_base (meta::RemoveReference< Derived > &derived) -> meta::Like< meta::RemoveReference< Derived > &, Base > &&
 
template<typename Derived, typename Base>
requires (concepts::DerivedFrom<meta::RemoveCVRef<Derived>, Base>)
constexpr auto forward_as_base (meta::RemoveReference< Derived > &&derived) -> meta::Like< meta::RemoveReference< Derived > &&, Base > &&
 
template<typename T, typename U>
constexpr auto forward_like (U &&value) -> decltype(auto)
 
template<types::size_t index, typename T>
constexpr auto get (T &&value) -> decltype(auto)
 
constexpr auto is_constant_evaluated () noexcept -> bool
 
template<typename... Args>
 NamedArguments (Args &&...) -> NamedArguments< Args &&... >
 
template<typename T>
 RebindableBox (T &&) -> RebindableBox< meta::UnwrapRefDecay< T > >
 
template<typename T>
constexpr auto make_rebindable_box (T &&value)
 
template<typename T>
 ReferenceWrapper (T &) -> ReferenceWrapper< T >
 
template<typename F>
 ScopeExit (F) -> ScopeExit< F >
 
template<typename T>
 ScopeValueChange (T &, T) -> ScopeValueChange< T >
 
void unreachable ()
 

Variables

constexpr auto clamp = detail::ClampFunction {}
 
constexpr auto clone = detail::CloneFunction {}
 
constexpr auto construct_at = detail::ConstructAtFunction {}
 
constexpr auto create_in_place = detail::CreateInPlaceFunction {}
 
constexpr auto deduce_create = detail::DeduceCreateFunction {}
 
constexpr auto default_construct_at = detail::DefaultConstructAtFunction {}
 
constexpr auto destroy_at = detail::DestroyAtFunction {}
 
constexpr auto get_in_place = GetInPlaceFunction {}
 
constexpr auto maybe_clone = detail::MaybeCloneFunction {}
 
template<typename Arg>
constexpr auto get_named_argument = detail::GetNamedArgumentFunction<Arg> {}
 A helper function to access a named argument.
 
template<typename Arg>
constexpr auto get_named_argument_or = detail::GetNamedArgumentOrFunction<Arg> {}
 A helper function to access a named argument or a fallback value.
 
constexpr auto ref = detail::RefFunction {}
 
constexpr auto cref = detail::CRefFunction {}
 
constexpr auto relocate = detail::RelocateFunction {}
 
constexpr struct di::util::SwapFunction swap
 
constexpr auto to_address = detail::ToAddressFunction {}
 
constexpr auto to_owned = detail::ToOwnedFunction {}
 
constexpr auto to_uintptr = detail::Function {}
 
constexpr auto to_underlying = detail::ToUnderlyingFunction {}
 
constexpr auto unwrap_reference = detail::UnwrapReferenceFunction {}
 
constexpr auto generate_uuid = detail::GenerateUUIDFunction {}
 
constexpr auto voidify = detail::VoidifyFunction {}
 

Function Documentation

◆ as_const_pointer()

template<typename T>
auto di::util::as_const_pointer ( T const * pointer)
constexpr

◆ black_box()

template<concepts::CopyConstructible T>
auto di::util::black_box ( T const & value) -> T

◆ compile_time_fail()

template<auto... values>
void di::util::compile_time_fail ( )

◆ compiler_barrier()

void di::util::compiler_barrier ( )
constexpr

Force to optimizer to reload memory addresses.

In certain cases, the compiler is able to cache the result of a read from a memory address. Inserting a compiler barrier will prevent this, and force the compiler to reload the value.

Warning
In most cases, it will be more clear to use a di::Atomic<> variable with relaxed memory ordering when this behavior is desired.

◆ create() [1/2]

template<typename T, typename... Args>
requires (concepts::LanguageVoid<T> || concepts::CreatableFrom<T, Args...>)
auto di::util::create ( Args &&... args)
constexpr

◆ create() [2/2]

template<template< typename... > typename Template, typename... Args>
requires (concepts::TemplateCreatableFrom<Template, Args...>)
auto di::util::create ( Args &&... args)
constexpr

◆ declval()

template<typename T>
auto di::util::declval ( ) -> meta::AddRValueReference<T>

◆ DeferConstruct()

template<typename T>
di::util::DeferConstruct ( T ) -> DeferConstruct< T >

◆ exchange()

template<typename T, typename U = T>
auto di::util::exchange ( T & object,
U && new_value ) -> T
constexpr

◆ forward_as_base() [1/2]

template<typename Derived, typename Base>
requires (concepts::DerivedFrom<meta::RemoveCVRef<Derived>, Base>)
auto di::util::forward_as_base ( meta::RemoveReference< Derived > && derived) -> meta::Like<meta::RemoveReference<Derived>&&, Base>&&
constexpr

◆ forward_as_base() [2/2]

template<typename Derived, typename Base>
requires (concepts::DerivedFrom<meta::RemoveCVRef<Derived>, Base>)
auto di::util::forward_as_base ( meta::RemoveReference< Derived > & derived) -> meta::Like<meta::RemoveReference<Derived>&, Base>&&
constexpr

◆ forward_like()

template<typename T, typename U>
auto di::util::forward_like ( U && value) -> decltype(auto)
nodiscardconstexpr

◆ get()

template<types::size_t index, typename T>
auto di::util::get ( T && value) -> decltype(auto)
constexpr

◆ is_constant_evaluated()

auto di::util::is_constant_evaluated ( ) -> bool
constexprnoexcept

◆ make_rebindable_box()

template<typename T>
auto di::util::make_rebindable_box ( T && value)
constexpr

◆ NamedArguments()

template<typename... Args>
di::util::NamedArguments ( Args && ...) -> NamedArguments< Args &&... >

◆ RebindableBox()

template<typename T>
di::util::RebindableBox ( T && ) -> RebindableBox< meta::UnwrapRefDecay< T > >

◆ ReferenceWrapper()

template<typename T>
di::util::ReferenceWrapper ( T & ) -> ReferenceWrapper< T >

◆ ScopeExit()

template<typename F>
di::util::ScopeExit ( F ) -> ScopeExit< F >

◆ ScopeValueChange()

template<typename T>
di::util::ScopeValueChange ( T & ,
T  ) -> ScopeValueChange< T >

◆ unreachable()

void di::util::unreachable ( )
inline

Variable Documentation

◆ clamp

auto di::util::clamp = detail::ClampFunction {}
inlineconstexpr

◆ clone

auto di::util::clone = detail::CloneFunction {}
inlineconstexpr

◆ construct_at

auto di::util::construct_at = detail::ConstructAtFunction {}
inlineconstexpr

◆ create_in_place

auto di::util::create_in_place = detail::CreateInPlaceFunction {}
inlineconstexpr

◆ cref

auto di::util::cref = detail::CRefFunction {}
inlineconstexpr

◆ deduce_create

auto di::util::deduce_create = detail::DeduceCreateFunction {}
inlineconstexpr

◆ default_construct_at

auto di::util::default_construct_at = detail::DefaultConstructAtFunction {}
inlineconstexpr

◆ destroy_at

auto di::util::destroy_at = detail::DestroyAtFunction {}
inlineconstexpr

◆ generate_uuid

auto di::util::generate_uuid = detail::GenerateUUIDFunction {}
inlineconstexpr

◆ get_in_place

auto di::util::get_in_place = GetInPlaceFunction {}
inlineconstexpr

◆ get_named_argument

template<typename Arg>
auto di::util::get_named_argument = detail::GetNamedArgumentFunction<Arg> {}
inlineconstexpr

A helper function to access a named argument.

Template Parameters
ArgThe type of the named argument.
Parameters
argsThe named arguments to access.
Returns
The value of the named argument.

This function is used to access a named argument from a list of named arguments. Note that it is a compile-time error to call this function with a named argument that is not present in the list of named arguments. Therefore, the concepts::HasNamedArgument concept should be used with an if constexpr block before calling this method. Otherwise, use the util::get_named_argument_or function.

Note
This function propogates the value-category of the passed named argument pack, which means that the named argument pack should be passed as an rvalue reference (unless of course, the named argument needs to be read multiple times).
See also
NamedArguments
get_named_argument_or

◆ get_named_argument_or

template<typename Arg>
auto di::util::get_named_argument_or = detail::GetNamedArgumentOrFunction<Arg> {}
inlineconstexpr

A helper function to access a named argument or a fallback value.

Template Parameters
ArgThe type of the named argument.
Parameters
argsThe named arguments to access.
fallbackThe fallback value to use if the named argument is not present.
Returns
The value of the named argument or the fallback value.

This function is used to access a named argument from a list of named arguments. If the named argument is not present in the list of named arguments, the fallback value is returned instead. To prevent dangling references, the returned argument is decay copied out.

Note
This function propogates the value-category of the passed named argument pack, which means that, to avoid copies, the named should be passed as an rvalue reference (unless of course, the named argument needs to be read multiple times).
When passed a template argument, the value-category of the returned argument is unchaged, and the return type is inferred based on the presence of the named argument, instead of always returning a common type.
See also
NamedArguments

◆ maybe_clone

auto di::util::maybe_clone = detail::MaybeCloneFunction {}
inlineconstexpr

◆ ref

auto di::util::ref = detail::RefFunction {}
inlineconstexpr

◆ relocate

auto di::util::relocate = detail::RelocateFunction {}
inlineconstexpr

◆ swap

struct di::util::SwapFunction di::util::swap

◆ to_address

auto di::util::to_address = detail::ToAddressFunction {}
inlineconstexpr

◆ to_owned

auto di::util::to_owned = detail::ToOwnedFunction {}
inlineconstexpr

◆ to_uintptr

auto di::util::to_uintptr = detail::Function {}
inlineconstexpr

◆ to_underlying

auto di::util::to_underlying = detail::ToUnderlyingFunction {}
inlineconstexpr

◆ unwrap_reference

auto di::util::unwrap_reference = detail::UnwrapReferenceFunction {}
inlineconstexpr

◆ voidify

auto di::util::voidify = detail::VoidifyFunction {}
inlineconstexpr