Classes | Typedefs | Functions | Variables

Traits of general utility. More...

Classes

struct  util::extract_to_tuple_type< SrcTuple, Extractor, TargetClass >
 Returns type TargetClass<U...> from a SrcTuple<T...>. More...
 
struct  util::index_of_extracted_type< Extractor, Target, Tuple >
 Returns the index of the element in Tuple with the specified type. More...
 
struct  util::has_extracted_type< Extractor, Target, Tuple >
 Trait holding whether an element in Tuple type contains Target. More...
 
struct  util::has_duplicate_extracted_types< Extractor, Tuple >
 Traits holding whether elements of Tuple have duplicate types. More...
 
struct  util::count_extracted_types< Extractor, Target, Tuple >
 Counts the elements of a tuple-like type containing a Target type. More...
 

Typedefs

template<typename SrcTuple , template< typename T, typename... > class Extractor, template< typename... > class TargetClass = std::tuple>
using util::extract_to_tuple_type_t = typename extract_to_tuple_type< SrcTuple, Extractor, TargetClass >::type
 Direct access to the type in extract_to_tuple_type. More...
 
template<typename Tuple , template< typename... > class TargetClass = std::tuple>
using util::to_tuple = extract_to_tuple_type< Tuple, self_type, TargetClass >
 
template<typename Tuple , template< typename... > class TargetClass = std::tuple>
using util::to_tuple_t = typename to_tuple< Tuple, TargetClass >::type
 Direct access to the type in to_tuple. More...
 
template<typename Target , typename Tuple >
using util::index_of_type = index_of_extracted_type< self_type, Target, Tuple >
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
using util::type_with_extracted_type = std::tuple_element< index_of_extracted_type_v< Extractor, Target, Tuple >, Tuple >
 Returns the element type in Tuple with the specified type. More...
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
using util::type_with_extracted_type_t = typename type_with_extracted_type< Extractor, Target, Tuple >::type
 Direct access to the value in type_with_extracted_type. More...
 
template<typename Target , typename Tuple >
using util::has_type = has_extracted_type< self_type, Target, Tuple >
 
template<typename Tuple >
using util::has_duplicate_types = has_duplicate_extracted_types< self_type, Tuple >
 
template<typename Target , typename Tuple >
using util::count_types = count_extracted_types< self_type, Target, Tuple >
 

Functions

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
auto util::getByExtractedType (Tuple const &data) -> decltype(auto)
 Returns the value of the element containing the specified type. More...
 

Variables

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr std::size_t util::index_of_extracted_type_v = index_of_extracted_type<Extractor, Target, Tuple>()
 Direct access to the value in index_of_extracted_type. More...
 
template<typename Target , typename Tuple >
constexpr std::size_t util::index_of_type_v = index_of_type<Target, Tuple>()
 Direct access to the value in index_of_type. More...
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr bool util::has_extracted_type_v = has_extracted_type<Extractor, Target, Tuple>()
 Direct access to the value in has_extracted_type. More...
 
template<typename Target , typename Tuple >
constexpr bool util::has_type_v = has_type<Target, Tuple>()
 Direct access to the value in has_type. More...
 
template<template< typename T, typename... > class Extractor, typename Tuple >
constexpr bool util::has_duplicate_extracted_types_v = has_duplicate_extracted_types<Extractor, Tuple>()
 Direct access to the value in has_duplicate_extracted_types. More...
 
template<typename Tuple >
constexpr bool util::has_duplicate_types_v = has_duplicate_types<Tuple>()
 Direct access to the value in has_duplicate_types. More...
 
template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr unsigned int util::count_extracted_types_v = count_extracted_types<Extractor, Target, Tuple>()
 Direct access to the value in count_extracted_types. More...
 
template<typename Target , typename Tuple >
constexpr unsigned int util::count_types_v = count_types<Target, Tuple>()
 Direct access to the value in count_extracted_types. More...
 

Detailed Description

Traits of general utility.

These traits are used in the implementation of the tag-related traits, but they are general enough that are deemed worth being exposed.

Typedef Documentation

template<typename Target , typename Tuple >
using util::count_types = typedef count_extracted_types<self_type, Target, Tuple>

Counts the number of Target elements in the specified Tuple.

See also
count_extracted_types, index_of_extracted_type_v, has_extracted_type_v, count_types_v

Definition at line 540 of file TupleLookupByTag.h.

template<typename SrcTuple , template< typename T, typename... > class Extractor, template< typename... > class TargetClass = std::tuple>
using util::extract_to_tuple_type_t = typedef typename extract_to_tuple_type<SrcTuple, Extractor, TargetClass>::type

Direct access to the type in extract_to_tuple_type.

Definition at line 205 of file TupleLookupByTag.h.

template<typename Tuple >
using util::has_duplicate_types = typedef has_duplicate_extracted_types<self_type, Tuple>

Like has_duplicate_extracted_types, but on the element types directly.

See also
has_duplicate_extracted_types, index_of_type, count_types, has_types, has_duplicate_types_v

Definition at line 483 of file TupleLookupByTag.h.

template<typename Target , typename Tuple >
using util::has_type = typedef has_extracted_type<self_type, Target, Tuple>

Like has_extracted_type, but querying the element types directly.

See also
has_extracted_type, index_of_type, count_types, has_type_v

Definition at line 392 of file TupleLookupByTag.h.

template<typename Target , typename Tuple >
using util::index_of_type = typedef index_of_extracted_type<self_type, Target, Tuple>

Like index_of_extracted_type, but querying the element types directly.

See also
index_of_extracted_type, index_of_type_v, has_type, count_types

Definition at line 271 of file TupleLookupByTag.h.

template<typename Tuple , template< typename... > class TargetClass = std::tuple>
using util::to_tuple = typedef extract_to_tuple_type<Tuple, self_type, TargetClass>

extract_to_tuple_type with no T-to-U type transformation.

See also
extract_to_tuple_type, to_tuple_t

Definition at line 212 of file TupleLookupByTag.h.

template<typename Tuple , template< typename... > class TargetClass = std::tuple>
using util::to_tuple_t = typedef typename to_tuple<Tuple, TargetClass>::type

Direct access to the type in to_tuple.

Definition at line 217 of file TupleLookupByTag.h.

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
using util::type_with_extracted_type = typedef std::tuple_element <index_of_extracted_type_v<Extractor, Target, Tuple>, Tuple>

Returns the element type in Tuple with the specified type.

Template Parameters
Extractorextract the candidate type from a Tuple element
Targetthe type being sought
Tupletuple-like data structure containing types.
See also
type_with_extracted_type_t, index_of_extracted_type, has_extracted_type, count_extracted_types, has_type,

Given a tuple-like type Tuple, this traits returns the one element type which "contains" the target type Target. For example:

template <typename T>
struct ExtractValueType { using type = typename T::value_type; };
using tuple_t = std::tuple<std::vector<std::string>, std::vector<int>>;
using int_container_t

int_container_t will be std::vector<int>, as the type in tuple_t with int as value_type.

If the target type is not present, or if it is present more than once, a compilation error will ensue.

Note
Currently there is no equivalent trait to ask for the second or following type; this can be implemented on request.

Definition at line 315 of file TupleLookupByTag.h.

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
using util::type_with_extracted_type_t = typedef typename type_with_extracted_type<Extractor, Target, Tuple>::type

Direct access to the value in type_with_extracted_type.

Definition at line 324 of file TupleLookupByTag.h.

Function Documentation

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
auto util::getByExtractedType ( Tuple const &  data) -> decltype(auto)

Returns the value of the element containing the specified type.

Template Parameters
Extractortrait extracting the target type from an element
Targetthe type sought
Tuplea tuple-like type to get values from
Parameters
datathe tuple to get data from
Returns
the value of the element containing the specified Target type
See also
count_extracted_types, index_of_extracted_type, has_extracted_type

The value of the selected element in data is returned, as in std::get. The value is taken from the element of data which contains the target type Target. The target type is extracted from each element in turn, using the Extractor` trait.

This function has the same limitations as util::index_of_extracted_type.

In the example:

template <typename T>
struct ExtractValueType { using type = typename T::value_type; };
auto myData = std::make_tuple(
std::vector<float>{ 1.5, 2.5 },
std::vector<int>{ 0, 2, 4 },
std::list<int>{ 1, 3, 5 }
);
decltype(auto) realData
= util::getByExtractedType<ExtractValueType, float>(data);

realData will be a reference std::vector<float>& to the element containing { 1.5, 2.5 }. Also note that in this example requesting the data of value type int will cause a compilation error since there is more than one element with that value type.

Definition at line 1260 of file TupleLookupByTag.h.

1261  {
1262  using std::get;
1263  return get<index_of_extracted_type_v<Extractor, Target, Tuple>>(data);
1264  }
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115

Variable Documentation

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr unsigned int util::count_extracted_types_v = count_extracted_types<Extractor, Target, Tuple>()

Direct access to the value in count_extracted_types.

Definition at line 533 of file TupleLookupByTag.h.

template<typename Target , typename Tuple >
constexpr unsigned int util::count_types_v = count_types<Target, Tuple>()

Direct access to the value in count_extracted_types.

Definition at line 544 of file TupleLookupByTag.h.

template<template< typename T, typename... > class Extractor, typename Tuple >
constexpr bool util::has_duplicate_extracted_types_v = has_duplicate_extracted_types<Extractor, Tuple>()

Direct access to the value in has_duplicate_extracted_types.

Definition at line 476 of file TupleLookupByTag.h.

template<typename Tuple >
constexpr bool util::has_duplicate_types_v = has_duplicate_types<Tuple>()

Direct access to the value in has_duplicate_types.

Definition at line 487 of file TupleLookupByTag.h.

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr bool util::has_extracted_type_v = has_extracted_type<Extractor, Target, Tuple>()

Direct access to the value in has_extracted_type.

Definition at line 386 of file TupleLookupByTag.h.

template<typename Target , typename Tuple >
constexpr bool util::has_type_v = has_type<Target, Tuple>()

Direct access to the value in has_type.

Definition at line 396 of file TupleLookupByTag.h.

template<template< typename T, typename... > class Extractor, typename Target , typename Tuple >
constexpr std::size_t util::index_of_extracted_type_v = index_of_extracted_type<Extractor, Target, Tuple>()

Direct access to the value in index_of_extracted_type.

Definition at line 264 of file TupleLookupByTag.h.

template<typename Target , typename Tuple >
constexpr std::size_t util::index_of_type_v = index_of_type<Target, Tuple>()

Direct access to the value in index_of_type.

Definition at line 276 of file TupleLookupByTag.h.