LArSoft
v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
|
Utilities to address elements of a tuple-like class by tag. More...
#include "larcorealg/CoreUtils/MetaUtils.h"
#include <tuple>
#include <type_traits>
#include <cstddef>
Go to the source code of this file.
Namespaces | |
util | |
Namespace for general, non-LArSoft-specific utilities. | |
util::details | |
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 > |
template<typename T , typename Tag > | |
using | util::add_tag_t = typename add_tag< T, Tag >::type |
template<typename Tagged > | |
using | util::remove_tag_t = typename remove_tag< Tagged >::type |
Direct access to the type contained in remove_tag . More... | |
template<typename Tagged > | |
using | util::tag_of = TagExtractor< Tagged > |
Trait holding the tag of Tagged as type . More... | |
template<typename Tagged > | |
using | util::tag_of_t = typename tag_of< Tagged >::type |
Direct access to the type in tag_of . More... | |
template<typename SrcTuple > | |
using | util::extract_tags = extract_to_tuple_type< SrcTuple, TagExtractor > |
Returns a tuple with all the tags from SrcTuple . More... | |
template<typename SrcTuple > | |
using | util::extract_tags_t = typename extract_tags< SrcTuple >::type |
Direct access to the type in extract_tags . More... | |
template<typename Tag , typename Tuple > | |
using | util::index_of_tag = index_of_extracted_type< TagExtractor, Tag, Tuple > |
Trait holding the index of the element of Tuple with tag Tag . More... | |
template<typename Tag , typename Tuple > | |
using | util::type_with_tag = type_with_extracted_type< TagExtractor, Tag, Tuple > |
Trait holding the type of the element of Tuple with tag Tag . More... | |
template<typename Tag , typename Tuple > | |
using | util::type_with_tag_t = typename type_with_tag< Tag, Tuple >::type |
Direct access to the value in type_with_tag . More... | |
template<typename Tag , typename Tuple > | |
using | util::has_tag = has_extracted_type< TagExtractor, Tag, Tuple > |
Trait informing if there are elements in Tuple with tag Tag . More... | |
template<typename Tag , typename Tuple > | |
using | util::count_tags = count_extracted_types< TagExtractor, Tag, Tuple > |
Trait counting the elements in Tuple with tag Tag . More... | |
template<typename Tuple > | |
using | util::has_duplicate_tags = has_duplicate_extracted_types< TagExtractor, Tuple > |
Trait reporting if multiple elements in Tuple have the same tag. More... | |
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... | |
template<typename Tag , typename T > | |
auto | util::makeTagged (T &obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tag , typename T > | |
auto | util::makeTagged (T const &obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tag , typename T > | |
auto | util::makeTagged (T const &&obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tag , typename T > | |
auto | util::makeTagged (T &&obj) -> decltype(auto) |
"Converts" obj to an object with tag Tag . More... | |
template<typename Tagged > | |
auto | util::removeTag (Tagged &tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tagged > | |
auto | util::removeTag (Tagged const &tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tagged > | |
auto | util::removeTag (Tagged const &&tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tagged > | |
auto | util::removeTag (Tagged &&tagged) -> decltype(auto) |
"Converts" a tagged type back to its original type. More... | |
template<typename Tag , typename Tuple > | |
auto | util::getByTag (Tuple const &data) -> decltype(auto) |
Returns the object with the specified tag. 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... | |
template<typename Tag , typename Tuple > | |
constexpr std::size_t | util::index_of_tag_v = index_of_tag<Tag, Tuple>() |
Direct access to the value in index_of_tag . More... | |
template<typename Tag , typename Tuple > | |
constexpr bool | util::has_tag_v = has_tag<Tag, Tuple>() |
Direct access to the value in has_tag . More... | |
template<typename Tag , typename Tuple > | |
constexpr unsigned int | util::count_tags_v = count_tags<Tag, Tuple>() |
Direct access to the value in count_tags . More... | |
template<typename Tuple > | |
constexpr bool | util::has_duplicate_tags_v = has_duplicate_tags<Tuple>() |
Direct access to the value in has_duplicate_tags . More... | |
template<typename Target , typename... T> | |
using | util::count_type_in_list = details::count_type_in_list_impl< Target, T... > |
Returns how many of the types in T exactly match Target . More... | |
template<std::size_t N, typename... T> | |
using | util::typelist_element_type = std::tuple_element< N, std::tuple< T... >> |
Returns the N type of the type list. More... | |
template<std::size_t N, typename... T> | |
using | util::typelist_element_t = typename typelist_element_type< N, T... >::type |
Direct access to the value in typelist_element_type . More... | |
template<typename Target , typename... T> | |
using | util::type_is_in = details::type_is_in_impl< Target, T... > |
Holds whether the Target type is among the ones in the T pack. More... | |
template<typename Target , typename... T> | |
constexpr unsigned int | util::count_type_in_list_v = count_type_in_list<Target, T...>() |
Direct access to the value in count_type_in_list . More... | |
template<typename Target , typename... T> | |
constexpr bool | util::type_is_in_v = type_is_in<Target, T...>() |
Direct access to the value in type_is_in . More... | |
Utilities to address elements of a tuple-like class by tag.
A "tagged" class is a class containing a type named "tag". The class is tagged by it. A container of objects, tuple-like, can be accessed by specifying the type of the tag. For example:
will assign tagBdata with one of the three components of the data
objects, the one whose type has tag
equal to TagB
.
The type being processed must be "tuple-like" (in the example above, the type of data
is in fact a tuple). This means that the type must respond to std::tuple_element
and std::tuple_size
.
Beside these utilities, equivalent utilities are exposed that allow a different definition of the tag (via a class "returning" the tag of its only template argument), and that operate on the types directly rather than on the tags (equivalent to define the tag as the object itself).
All the type trait utilities follow the standard C++ convention: the ones "returning" a type have that type in a type
member, and the ones returning a value have that value in a value
member, and their instances can be implicitly converted to that value. Aliases ending with _t
and _v
are also provided.
This is a header-only library providing mostly type trait information.
Definition in file TupleLookupByTag.h.