Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Static Private Member Functions | Friends | List of all members
named< T, NAMES > Struct Template Reference

named container More...

#include <named.h>

Inherits T.

Public Types

using value_type = T
 

Public Member Functions

template<typename... Ts>
constexpr named (Ts &&...ts)
 Forwarding constructor.
 
template<typename U , string_literal... UNAMES>
requires (sizeof...(NAMES) == sizeof...(UNAMES))
constexpr named (named< U, UNAMES... > &&src)
 Reshuffle constructor (based on matching names)
 
template<typename U , string_literal... UNAMES>
requires (sizeof...(NAMES) == sizeof...(UNAMES))
constexpr named (const named< U, UNAMES... > &src)
 Reshuffle constructor (based on matching names)
 
template<typename U , string_literal... UNAMES>
requires (sizeof...(NAMES) == sizeof...(UNAMES))
named operator= (const named< U, UNAMES... > &src)
 reshuffle assignment
 
template<typename... Ts>
requires (sizeof...(NAMES) == sizeof...(Ts))
named operator= (const std::tuple< Ts... > &src)
 unnamed assignment
 
constexpr T & values (void)
 \names Querry/cast values from the underlying container
 
constexpr const T & values (void) const
 
constexpr operator T (void)
 
'get' by name or index
template<size_t IDX>
constexpr decltype(auto) get (void)
 
template<size_t IDX>
constexpr decltype(auto) get (void) const
 
template<string_literal NAME, string_literal... SUBNAME>
constexpr decltype(auto) get (void)
 
template<string_literal NAME, string_literal... SUBNAME>
constexpr decltype(auto) get (void) const
 

Static Public Attributes

template<size_t IDX>
static constexpr auto name = std::get<IDX>(std::make_tuple(NAMES...))
 query name by index
 
static constexpr auto names = std::make_tuple(NAMES...)
 tuple of all names
 
template<string_literal NAME>
static constexpr bool has_name = (named<T,NAMES...>::template _find_name<0,NAME,NAMES...>() != sizeof...(NAMES))
 check if has_name
 
template<string_literal NAME>
static constexpr size_t find_name = named<T,NAMES...>::template _find_name<0,NAME,NAMES...>()
 find index of name (size if not found); uses a linear search
 
static constexpr size_t size = sizeof...(NAMES)
 size (number of names/elements in value_type)
 

Static Private Member Functions

template<size_t IDX, string_literal NAME, string_literal N, string_literal... Ns>
static constexpr size_t _find_name (void)
 

Friends

std::ostream & operator<< (std::ostream &s, const named &n)
 ostream
 

Detailed Description

template<typename T, string_literal... NAMES>
requires (sizeof...(NAMES) == 0) || (concepts::gettable<T> && (sizeof...(NAMES) == std::tuple_size_v<std::decay_t<T>>))
struct bbm::named< T, NAMES >

named container

Template Parameters
T= underlying container type; must support std::get and std::tuple_size_v
NAMES= names of each element

Member Typedef Documentation

◆ value_type

using value_type = T

Constructor & Destructor Documentation

◆ named() [1/3]

constexpr named ( Ts &&...  ts)
inlineconstexpr

Forwarding constructor.

◆ named() [2/3]

constexpr named ( named< U, UNAMES... > &&  src)
inlineconstexpr

Reshuffle constructor (based on matching names)

◆ named() [3/3]

constexpr named ( const named< U, UNAMES... > &  src)
inlineconstexpr

Reshuffle constructor (based on matching names)

Member Function Documentation

◆ _find_name()

static constexpr size_t _find_name ( void  )
inlinestaticconstexprprivate

◆ get() [1/4]

constexpr decltype(auto) get ( void  )
inlineconstexpr

◆ get() [2/4]

constexpr decltype(auto) get ( void  )
inlineconstexpr

◆ get() [3/4]

constexpr decltype(auto) get ( void  ) const
inlineconstexpr

◆ get() [4/4]

constexpr decltype(auto) get ( void  ) const
inlineconstexpr

◆ operator T()

constexpr operator T ( void  )
inlineconstexpr

◆ operator=() [1/2]

named operator= ( const named< U, UNAMES... > &  src)
inline

reshuffle assignment

◆ operator=() [2/2]

named operator= ( const std::tuple< Ts... > &  src)
inline

unnamed assignment

◆ values() [1/2]

constexpr T & values ( void  )
inlineconstexpr

\names Querry/cast values from the underlying container

◆ values() [2/2]

constexpr const T & values ( void  ) const
inlineconstexpr

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const named< T, NAMES > &  n 
)
friend

ostream

Member Data Documentation

◆ find_name

constexpr size_t find_name = named<T,NAMES...>::template _find_name<0,NAME,NAMES...>()
staticconstexpr

find index of name (size if not found); uses a linear search

◆ has_name

constexpr bool has_name = (named<T,NAMES...>::template _find_name<0,NAME,NAMES...>() != sizeof...(NAMES))
staticconstexpr

check if has_name

◆ name

constexpr auto name = std::get<IDX>(std::make_tuple(NAMES...))
staticconstexpr

query name by index

◆ names

constexpr auto names = std::make_tuple(NAMES...)
staticconstexpr

tuple of all names

◆ size

constexpr size_t size = sizeof...(NAMES)
staticconstexpr

size (number of names/elements in value_type)


The documentation for this struct was generated from the following file: