stlab 2.3.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
Loading...
Searching...
No Matches
utility

Detailed Description

Type utilities (move, copy, static_max, etc.).

Classes

struct  stlab::index_sequence_cat< Seq1, Seq2 >
struct  stlab::index_sequence_cat< std::index_sequence< N1... >, std::index_sequence< N2... > >
struct  stlab::index_sequence_to_array< Seq >
struct  stlab::index_sequence_to_array< std::index_sequence< N... > >
struct  stlab::index_sequence_transform< Seq, F, Index, Count >
struct  stlab::index_sequence_transform< Seq, F, Index, 0 >
struct  stlab::index_sequence_transform< Seq, F, Index, 1 >

Typedefs

template<class Seq1, class Seq2>
using stlab::index_sequence_cat_t
template<class Seq, template< std::size_t > class F, std::size_t Index = 0, std::size_t Count = Seq::size()>
using stlab::index_sequence_transform_t

Functions

template<bool P, class T>
constexpr auto stlab::move_if (T &&t) noexcept -> detail::move_if_helper_t< P, T >
 If P is true, casts t to an rvalue; otherwise keeps an lvalue reference.
template<class F, class... Args>
void stlab::for_each_argument (F &&f, Args &&... args)
 Invokes f(arg0), f(arg1), … f(argN).
template<typename T>
constexpr auto stlab::copy (T &&value) noexcept(noexcept(std::decay_t< T >{static_cast< T && >(value)})) -> std::decay_t< T >
 Returns a copy of the argument. Used to pass an lvalue to a function taking an rvalue, or to copy a type with an explicit copy constructor.
template<class T>
constexpr auto stlab::move (T &&t) noexcept -> std::remove_reference_t< T > &&
 A standard move implementation but with a compile-time check for const types.

Function Documentation

◆ copy()

template<typename T>
auto stlab::copy ( T && value) -> std::decay_t< T >
constexprnoexcept

Returns a copy of the argument. Used to pass an lvalue to a function taking an rvalue, or to copy a type with an explicit copy constructor.

Example
void f(std::vector<int>&&);
std::vector<int> c = ...;
f(copy(c)); // pass a copy of c
f(move(c)); // sink c
constexpr auto copy(T &&value) noexcept(noexcept(std::decay_t< T >{static_cast< T && >(value)})) -> std::decay_t< T >
Returns a copy of the argument. Used to pass an lvalue to a function taking an rvalue,...
Definition utility.hpp:144
constexpr auto move(T &&t) noexcept -> std::remove_reference_t< T > &&
A standard move implementation but with a compile-time check for const types.
Definition utility.hpp:154

◆ for_each_argument()

template<class F, class... Args>
void stlab::for_each_argument ( F && f,
Args &&... args )

Invokes f(arg0), f(arg1), … f(argN).

Parameters
fUnary function invoked once per argument.
argsArguments passed one-by-one to f.