TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
Other utilities

Detailed Description

Other general-purpose utilities.

Classes

struct  triqs::utility::dressed_iterator< IteratorType, Dressing, DressingAuxiliaryArgumentPtrType >
 STL-compatible iterator that wraps an underlying iterator and dereferences to a user-supplied dressing type. More...
struct  triqs::utility::dressed_iterator< IteratorType, Dressing, void >
 Specialization of triqs::utility::dressed_iterator for the case where no auxiliary pointer is needed. More...
class  triqs::utility::scope_guard< F >
 RAII wrapper that invokes a callable when it goes out of scope, unless dismissed. More...

Typedefs

using dcomplex = std::complex<double>
 Convenience alias for std::complex<double>.

Functions

std::string triqs::utility::demangle (const char *name)
 Demangle a mangled C++ symbol name to a human-readable string.
std::string triqs::utility::demangle (std::string const &name)
 Overload of demangle accepting an std::string.
template<class F>
scope_guard< F > triqs::utility::exec_at_scope_exit (F f)
 Build a scope_guard from a callable.
template<typename T, typename... U>
triqs::utility::factory (U &&...x)
 Generic factory to construct an object of a given type from an arbitrary parameter pack of arguments.
std::string triqs::utility::get_name (std::type_info const &info)
 Demangle the name corresponding to an std::type_info.
template<int NArgs, typename Lambda, typename T>
decltype(auto) triqs::utility::make_lazy_bracket (Lambda &&f, T const &x)
 Invoke a callable lazily by accumulating arguments through chained operator[] calls.
template<class F>
scope_guard< F > triqs::utility::make_scope_guard (F f)
 Build a scope_guard from a callable.
template<typename T>
std::string triqs::utility::typeid_name ()
 Human-readable name of a given static type.
template<typename T>
std::string triqs::utility::typeid_name (T const &obj)
 Human-readable name of the dynamic type of a given object.

Function Documentation

◆ demangle()

std::string triqs::utility::demangle ( const char * name)

#include <triqs/utility/typeid_name.cpp>

Demangle a mangled C++ symbol name to a human-readable string.

Parameters
nameMangled name (typically typeid(...).name()).
Returns
The demangled name, or the original name if demangling failed.

Definition at line 35 of file typeid_name.cpp.

◆ exec_at_scope_exit()

template<class F>
scope_guard< F > triqs::utility::exec_at_scope_exit ( F f)

#include <triqs/utility/scope_guard.hpp>

Build a scope_guard from a callable.

The returned object must be bound to a named variable.

Template Parameters
FCallable type.
Parameters
fCallable to run at scope exit.
Returns
A scope guard wrapping f.

Definition at line 112 of file scope_guard.hpp.

◆ factory()

template<typename T, typename... U>
T triqs::utility::factory ( U &&... x)

#include <triqs/utility/factory.hpp>

Generic factory to construct an object of a given type from an arbitrary parameter pack of arguments.

The actual construction is delegated to the helper class detail::factories<T>, whose static invoke member is called with the forwarded arguments. By default detail::factories<T> simply forwards its single argument to a constructor of T, so any type that is directly constructible from the given argumnets works out of the box.

To support custom construction logic for a type T (e.g. element-wise conversion, allocation, or building from a different representation), provide a partial or full specialization of detail::factories<T> exposing one or more static invoke overloads that return a T. The library already specializes it for std::vector<T> to allow constructing a vector from another vector with element-wise conversion.

Template Parameters
TTarget type.
UArgument types.
Parameters
xConstructor arguments.
Returns
A newly constructed T instance.

Definition at line 95 of file factory.hpp.

◆ get_name()

std::string triqs::utility::get_name ( std::type_info const & info)

#include <triqs/utility/typeid_name.cpp>

Demangle the name corresponding to an std::type_info.

Parameters
infoType info object.
Returns
The demangled name, or the original name if demangling failed.

Definition at line 57 of file typeid_name.cpp.

◆ make_lazy_bracket()

template<int NArgs, typename Lambda, typename T>
decltype(auto) triqs::utility::make_lazy_bracket ( Lambda && f,
T const & x )

#include <triqs/utility/lazy_bracket.hpp>

Invoke a callable lazily by accumulating arguments through chained operator[] calls.

Warning
This is unused. It might be removed in the future.
Template Parameters
NArgsTotal number of expected arguments.
LambdaCallable type.
TType of the first argument.
Parameters
fCallable to invoke once all indices are collected.
xFirst argument.
Returns
Either f(x) (when NArgs == 1) or a lazy object expecting more operator[] calls.

Definition at line 82 of file lazy_bracket.hpp.

◆ make_scope_guard()

template<class F>
scope_guard< F > triqs::utility::make_scope_guard ( F f)

#include <triqs/utility/scope_guard.hpp>

Build a scope_guard from a callable.

The returned object must be bound to a named variable.

Template Parameters
FCallable type.
Parameters
fCallable to run at scope exit.
Returns
A scope guard wrapping f.

Definition at line 123 of file scope_guard.hpp.

◆ typeid_name() [1/2]

template<typename T>
std::string triqs::utility::typeid_name ( )

#include <triqs/utility/typeid_name.hpp>

Human-readable name of a given static type.

Template Parameters
TType of interest.
Returns
Demangled name of T.

Definition at line 71 of file typeid_name.hpp.

◆ typeid_name() [2/2]

template<typename T>
std::string triqs::utility::typeid_name ( T const & obj)

#include <triqs/utility/typeid_name.hpp>

Human-readable name of the dynamic type of a given object.

Template Parameters
TType of the object.
Parameters
objObject whose type name is requested.
Returns
Demangled name of the dynamic type of the given object.

Definition at line 63 of file typeid_name.hpp.