Metafunction
Is
Returns whether a concept is fulfilled.
Include Headers
seqan/basic.h
Parameters
A concept that is specialized with type(s) that should be tested for fulfilling the concept. |
Remarks
The Is-metafunction can be used to test types for fulfilling a concept without causing compilation errors.
If True/true is returned, TConcept must pass the concept test via SEQAN_CONCEPT_ASSERT.
It can be used to switch between different implementations depending on the concept of a type, or in combination with SEQAN_FUNC_ENABLE_IF to make a function only visible to types of certain concepts.
Examples
IfC<Is<ContainerConcept<TSeq> >::VALUE, T1, T2>::Type
std::cout << Is<IntegerConcept<int> >::VALUE << std::endl; // 1
std::cout << Is<IntegerConcept<double> >::VALUE << std::endl; // 0
Define a hierarchy of concepts and two models Alice and Bob that implements some of them.
Is determines which concepts are explicitly or implicitly fulfilled.
struct Bob {};
SEQAN_CONCEPT(ConceptA, (T)) {};
SEQAN_CONCEPT(ConceptB, (T)) {};
SEQAN_CONCEPT_REFINE(ConceptC, (T), (ConceptA)(ConceptB)) {};
SEQAN_CONCEPT_REFINE(ConceptD, (T), (ConceptC)) {};
SEQAN_CONCEPT_IMPL(Alice, (ConceptA)(ConceptB));
SEQAN_CONCEPT_IMPL(Bob, (ConceptC));
std::cout << Is< ConceptA<Alice> >::VALUE << std::endl; // 1
std::cout << Is< ConceptB<Alice> >::VALUE << std::endl; // 1
std::cout << Is< ConceptC<Alice> >::VALUE << std::endl; // 0
std::cout << Is< ConceptD<Alice> >::VALUE << std::endl; // 0
std::cout << Is< ConceptA<Bob> >::VALUE << std::endl; // 1
std::cout << Is< ConceptB<Bob> >::VALUE << std::endl; // 1
std::cout << Is< ConceptC<Bob> >::VALUE << std::endl; // 1
std::cout << Is< ConceptD<Bob> >::VALUE << std::endl; // 0
See Also
SeqAn - Sequence Analysis Library - www.seqan.de