util::has_extracted_type< Extractor, Target, Tuple > Struct Template Reference

Trait holding whether an element in Tuple type contains Target. More...

#include <TupleLookupByTag.h>

Inheritance diagram for util::has_extracted_type< Extractor, Target, Tuple >:

Detailed Description

template<template< typename T, typename... > class Extractor, typename Target, typename Tuple>
struct util::has_extracted_type< Extractor, Target, Tuple >

Trait holding whether an element in Tuple type contains Target.

Template Parameters
Extractortrait exposing the target type in an element
Targetthe target type to be found
Tuplethe tuple-like type to be investigated
See also
has_extracted_type_v, index_of_extracted_type, count_extracted_types, has_type

Given a tuple-like type Tuple, this trait returns whether there is at least an 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<float>, std::vector<int>, std::list<int>>;
constexpr bool hasIntegerContainers
constexpr bool hasDoubleContainers

hasIntegerContainers will hold value true, meaning there are two types with int as value_type. Likewise, hasDoubleContainers will be false.

Note
Before C++17, the following construct is invalid: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} using tuple_t = std::tuple<std::vector<float>, std::vector<int>, std::list<int>>; tuple_t data { { 0.5, 1.5 }, { 0, 2, 4 }, { 1, 3, 5 } }; if (util::has_extracted_type<ExtractValueType, int, tuple_t>()) return util::getByExtractedType<ExtractValueType, int>(data); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ because util::getByExtractedType<ExtractValueType, double>(data) needs to be compilable, but it is not since it has more than one int extracted types. This is solved in C++17 by the use of a "constexpr if".

Definition at line 377 of file TupleLookupByTag.h.


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