LArSoft
v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
|
Traits for types with a tag
.
More...
Classes | |
struct | util::TaggedType< T, Tag > |
A type with a specified tag. More... | |
struct | util::add_tag< T, Tag > |
struct | util::remove_tag< Tagged > |
Trait holding the type contained in a TaggedType (or the type itself). More... | |
struct | util::remove_tag< TaggedType< T, Tag > > |
struct | util::TagN<... > |
Tag class parametrized by a sequence of numbers. More... | |
struct | util::TagExtractor< Tagged > |
Extracts the tag from a type. More... | |
Typedefs | |
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<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<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... | |
Traits for types with a tag
.
Tag-related traits operate on "tagged" types. A tagged type is a type which contains a tag
type definition, and that type is the tag type.
In the examples, the types used are defined as:
Note that DuplTuple_t
has two elements with the same tag (TagA
).
using util::add_tag_t = typedef typename add_tag<T, Tag>::type |
Direct access to the type contained in add_tag
.
TaggedType
Definition at line 617 of file TupleLookupByTag.h.
using util::count_tags = typedef count_extracted_types<TagExtractor, Tag, Tuple> |
Trait counting the elements in Tuple
with tag Tag
.
Tag | the sought tag |
Tuple | the tuple-like type holding the elements to check |
index_of_tag
, count_tags_v
, has_duplicate_tags
, has_tag
Given a tuple-like type Tuple
, this traits returns the number of element types tagged with Tag
.
For example (see above for the definitions):
nTagA
, nTagB
and nTagC
, will be 1
and nTagD
will be 0
. Likewise, nTagAdupl
will be 1
, nTagBdupl
will be 2
, while nTagCdupl
and nTagDdupl
will be 0
.
Definition at line 885 of file TupleLookupByTag.h.
using util::extract_tags = typedef extract_to_tuple_type<SrcTuple, TagExtractor> |
Returns a tuple with all the tags from SrcTuple
.
Definition at line 744 of file TupleLookupByTag.h.
using util::extract_tags_t = typedef typename extract_tags<SrcTuple>::type |
Direct access to the type in extract_tags
.
Definition at line 748 of file TupleLookupByTag.h.
using util::has_duplicate_tags = typedef has_duplicate_extracted_types<TagExtractor, Tuple> |
Trait reporting if multiple elements in Tuple
have the same tag.
Tuple | the tuple-like type holding the elements to check |
index_of_tag
, count_tags
, has_duplicate_tags_v
, has_tag
Given a tuple-like type Tuple
, this traits returns whether any of the tags in the elements appears more than once.
For example (see above for the definitions):
hasDuplTags
, will be false
and hasDuplTagsDupl
will be true
.
Definition at line 908 of file TupleLookupByTag.h.
using util::has_tag = typedef has_extracted_type<TagExtractor, Tag, Tuple> |
Trait informing if there are elements in Tuple
with tag Tag
.
Tag | the sought tag |
Tuple | the tuple-like type holding the elements to check |
index_of_tag
, count_tags
, has_duplicate_tags
, has_tag_v
Given a tuple-like type Tuple
, this traits returns whether there is at least one element type tagged with Tag
.
For example (see above for the definitions):
hasTagA
, hasTagB
and hasTagC
, will be true
and hasTagD
will be false
. Likewise, hasTagAdupl
and hasTagBdupl
will be true
, while hasTagCdupl
and hasTagDdupl
will be false
.
Definition at line 853 of file TupleLookupByTag.h.
using util::index_of_tag = typedef index_of_extracted_type<TagExtractor, Tag, Tuple> |
Trait holding the index of the element of Tuple
with tag Tag
.
Tag | the sought tag |
Tuple | the tuple-like type holding the elements to check |
index_of_tag_v
, count_tags
, has_duplicate_tags
, has_tag
Given a tuple-like type Tuple
, this traits returns the index of the one element type tagged with Tag
. If the target type is not present, or if it is present more than once, a compilation error will ensue.
For example (see above for the definitions):
TagAindex
will hold value 0
, pointing to the container in Tuple_t
of type IntTaggedA
, while TagBindex
will be 1
and TagBduplIndex
will be also 1
. Instead, the expression util::index_of_tag<TagD, Tuple_t>()
would not compile because no element in Tuple_t
is tagged with TagD
, and the expression util::index_of_tag<TagA, DuplTuple_t>()
would not compile because two elements of DuplTuple_t
are tagged TagA
.
Definition at line 782 of file TupleLookupByTag.h.
using util::remove_tag_t = typedef typename remove_tag<Tagged>::type |
Direct access to the type contained in remove_tag
.
Definition at line 630 of file TupleLookupByTag.h.
using util::tag_of = typedef TagExtractor<Tagged> |
Trait holding the tag of Tagged
as type
.
Definition at line 735 of file TupleLookupByTag.h.
using util::tag_of_t = typedef typename tag_of<Tagged>::type |
Direct access to the type in tag_of
.
Definition at line 739 of file TupleLookupByTag.h.
using util::type_with_tag = typedef type_with_extracted_type<TagExtractor, Tag, Tuple> |
Trait holding the type of the element of Tuple
with tag Tag
.
Tag | the sought tag |
Tuple | the tuple-like type holding the elements to check |
type_with_tag_t
, index_of_tag
, count_tags
, has_duplicate_tags
, has_tag
Given a tuple-like type Tuple
, this traits returns the one element type tagged with Tag
. If the target type is not present, or if it is present more than once, a compilation error will ensue.
For example (see above for the definitions):
TagA_t
will be IntTaggedA
, the type in Tuple_t
with TagA
, while TagB_t
will be DoubleTaggedB
and TagBdupl_t
will be also DoubleTaggedB
. Instead, the type util::type_with_tag<TagD, Tuple_t>
would not compile because no element in Tuple_t
is tagged with TagD
, and the type util::type_with_tag<TagA, DuplTuple_t>()
would not compile because two elements of DuplTuple_t
are tagged TagA
.
Definition at line 820 of file TupleLookupByTag.h.
using util::type_with_tag_t = typedef typename type_with_tag<Tag, Tuple>::type |
Direct access to the value in type_with_tag
.
Definition at line 825 of file TupleLookupByTag.h.
auto util::getByTag | ( | Tuple const & | data | ) | -> decltype(auto) |
Returns the object with the specified tag.
Tag | the sought tag |
Tuple | the tuple-like type holding the data |
index_of_tag
, count_tags
, has_duplicate_tags
, has_tag
This function operates in a fashion similar to std::get()
, where instead of specifying the index or type of the object to retrieve, the tag is specified.
For example (see above for the definitions):
TagBdata
will be a reference to a std::vector<double>
in data
, currently with values { 0.5, 1.5 }". The attempt to use
util::getByTag()on an argument with duplicate tags (like
DuplTuple_t`) will ensue a compilation error.
Definition at line 940 of file TupleLookupByTag.h.
auto util::makeTagged | ( | T & | obj | ) | -> decltype(auto) |
"Converts" obj
to an object with tag Tag
.
Tag | tag to be added to the object |
T | type of the object to be tagged (implicitly deduced) |
obj | (l-value) reference to the object to be tagged |
obj
, reinterpreted as tagged TaggedType
, add_tag
The returned object is the same as obj
, reinterpreted as a different type derived from T
and tagged with Tag
.
Definition at line 645 of file TupleLookupByTag.h.
auto util::makeTagged | ( | T const & | obj | ) | -> decltype(auto) |
"Converts" obj
to an object with tag Tag
.
Tag | tag to be added to the object |
T | type of the object to be tagged (implicitly deduced) |
obj | (l-value) constant reference to the object to be tagged |
obj
, reinterpreted as tagged TaggedType
, add_tag
The returned object is the same as obj
, reinterpreted as a different type derived from T
and tagged with Tag
.
Definition at line 660 of file TupleLookupByTag.h.
auto util::makeTagged | ( | T const && | obj | ) | -> decltype(auto) |
"Converts" obj
to an object with tag Tag
.
Tag | tag to be added to the object |
T | type of the object to be tagged (implicitly deduced) |
obj | (r-value) reference to the object to be tagged |
obj
, reinterpreted as tagged TaggedType
, add_tag
The returned object is an object of a new type, derived from T
, with data copied from obj
, and tagged with Tag
. The argument object may be a temporary.
Definition at line 676 of file TupleLookupByTag.h.
auto util::makeTagged | ( | T && | obj | ) | -> decltype(auto) |
"Converts" obj
to an object with tag Tag
.
Tag | tag to be added to the object |
T | type of the object to be tagged (implicitly deduced) |
obj | the object to be tagged |
obj
, reinterpreted as tagged TaggedType
, add_tag
The returned object is the same as obj
, reinterpreted as a different type derived from T
and tagged with Tag
. The returned object is a temporary of the new type, whose content is moved (std::move()
) from the argument object obj
.
Definition at line 693 of file TupleLookupByTag.h.
auto util::removeTag | ( | Tagged & | tagged | ) | -> decltype(auto) |
"Converts" a tagged type back to its original type.
Definition at line 698 of file TupleLookupByTag.h.
auto util::removeTag | ( | Tagged const & | tagged | ) | -> decltype(auto) |
"Converts" a tagged type back to its original type.
Definition at line 703 of file TupleLookupByTag.h.
auto util::removeTag | ( | Tagged const && | tagged | ) | -> decltype(auto) |
"Converts" a tagged type back to its original type.
Definition at line 708 of file TupleLookupByTag.h.
auto util::removeTag | ( | Tagged && | tagged | ) | -> decltype(auto) |
"Converts" a tagged type back to its original type.
Definition at line 713 of file TupleLookupByTag.h.
constexpr unsigned int util::count_tags_v = count_tags<Tag, Tuple>() |
Direct access to the value in count_tags
.
Definition at line 889 of file TupleLookupByTag.h.
constexpr bool util::has_duplicate_tags_v = has_duplicate_tags<Tuple>() |
Direct access to the value in has_duplicate_tags
.
Definition at line 912 of file TupleLookupByTag.h.
constexpr bool util::has_tag_v = has_tag<Tag, Tuple>() |
Direct access to the value in has_tag
.
Definition at line 857 of file TupleLookupByTag.h.
constexpr std::size_t util::index_of_tag_v = index_of_tag<Tag, Tuple>() |
Direct access to the value in index_of_tag
.
Definition at line 787 of file TupleLookupByTag.h.