ccutl  0.3.2
a C++ utilities library focused on flexibility and expressibility
Public Types | Public Member Functions | Static Public Attributes | List of all members
ctl::type_pack< Ts > Struct Template Reference

#include <ccutl.h>

Public Types

template<template< class... > class Template, typeof< Template > T>
using from = typename detail::type_pack::from< Template, T >::template type< Ts... >
 
template<template< class... > class Template>
using to = Template< Ts... >
 
template<class T >
using push_back = type_pack< Ts..., T >
 
template<class T >
using push_front = type_pack< T, Ts... >
 
template<typeof< type_pack > Other>
using concat = typename detail::type_pack::concat< Other >::template type< Ts... >
 

Public Member Functions

constexpr type_pack (const type_pack< Ts... > &)=default
 
constexpr type_pack (type_pack< Ts... > &&)=default
 
template<template< class... > class Template, class... Us>
constexpr type_pack (const Template< Us... > &) noexcept
 Placeholder constructor for deduction-guide construction.
 
template<template< class... > class Template, class... Us>
constexpr type_pack (Template< Us... > &&) noexcept
 Placeholder constructor for deduction-guide construction.
 
template<std::size_t idx>
 requires (idx< size) using get
 
template<std::size_t n_removed = 1ul>
 requires (size >=n_removed) using pop_back
 
template<std::size_t n_removed = 1ul>
 requires (size >=n_removed) using pop_front
 
template<std::size_t begin, std::size_t end = size>
 requires (size >=0 and begin<=end and end<=size) using slice
 

Static Public Attributes

static constexpr std::size_t size = sizeof...(Ts)
 Represents the number of types in the pack.
 

Detailed Description

template<class... Ts>
struct ctl::type_pack< Ts >

Provides a template type arg container with transformational utilities

#include <tuple>
#include <ctl/type_pack.h>
using std::tuple;
using t0 = ctl::type_pack<>; // type_pack<>
using t1 = t0::push_back<int>; // type_pack<int>
using t2 = t1::push_front<unsigned>; // type_pack<unsigned, int>
using t3 = t2::concat<type_pack<long, char>>; // type_pack<unsigned, int,
long, char>
using t4 = t3::pop_back<>; // type_pack<unsigned, int,
long>
using t5 = t4::pop_front<2>; // type_pack<long>
using t6 = t5::to<tuple>; // tuple<long>
using t7 = t5::get<0>; // long
//
auto sz = t5::size; // 1

Member Typedef Documentation

◆ concat

template<class... Ts>
template<typeof< type_pack > Other>
using ctl::type_pack< Ts >::concat = typename detail::type_pack::concat<Other>::template type<Ts...>

Represents a type_pack with types from the concatenation of another type_pack – <this..., other...>

Template Parameters
Other- Other type_pack to concatenate

◆ from

template<class... Ts>
template<template< class... > class Template, typeof< Template > T>
using ctl::type_pack< Ts >::from = typename detail::type_pack::from<Template, T>::template type<Ts...>

Creates a type_pack from all type template arguments in a type template

Template Parameters
Template- Template name
T[Template<class...>] - Type to grab arguments from
type_pack<>::from<Template<int, float>>; // -> type_pack<int, float>

◆ push_back

template<class... Ts>
template<class T >
using ctl::type_pack< Ts >::push_back = type_pack<Ts..., T>

Represents a type_pack with T pushed to the back

Template Parameters
T- Type to push back

◆ push_front

template<class... Ts>
template<class T >
using ctl::type_pack< Ts >::push_front = type_pack<T, Ts...>

Represents a type_pack with T pushed to the front

Template Parameters
T- Type to push front

◆ to

template<class... Ts>
template<template< class... > class Template>
using ctl::type_pack< Ts >::to = Template<Ts...>

Represents a type-specialized template using the types in this pack

Template Parameters
Template- Template to type-specialize

Member Function Documentation

◆ requires() [1/4]

template<class... Ts>
template<std::size_t idx>
ctl::type_pack< Ts >::requires ( )

Represents a type from the pack at index idx

Template Parameters
idx- Index to retrieve

◆ requires() [2/4]

template<class... Ts>
template<std::size_t begin, std::size_t end = size>
ctl::type_pack< Ts >::requires ( size >=0 and begin<=end and end<=  size)

Represents a type_pack from a slice of this pack [begin, end)

Template Parameters
begin- First element index
end- Element index following last element index

◆ requires() [3/4]

template<class... Ts>
template<std::size_t n_removed = 1ul>
ctl::type_pack< Ts >::requires ( size >=  n_removed)

Represents a type_pack with its last n_removed elements removed

Template Parameters
n_removed[ =1 ] - Number of elements to remove

◆ requires() [4/4]

template<class... Ts>
template<std::size_t n_removed = 1ul>
ctl::type_pack< Ts >::requires ( size >=  n_removed)

Represents a type_pack with its first n_removed elements removed

Template Parameters
n_removed[ =1 ] - Number of elements to remove

The documentation for this struct was generated from the following file:
ctl::type_pack::from
typename detail::type_pack::from< Template, T >::template type< Ts... > from
Definition: ccutl.h:1717