Fn<> Is
Returns whether a concept is fulfilled.

Defined in <seqan/basic.h>
Signature Is<TConcept>::Type Is<TConcept>::VALUE

Template Parameters

TConcept A concept that is specialized with type(s) that should be tested for fulfilling the concept.

Return Values

Type True/true if TConcept is a fulfilled concept, otherwise False/false.

Detailed Description

The Is-metafunction can be used to test types for fulfilling a concept without causing compilation errors. If True or 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.


Is<SequenceConcept<TSeq> >::Type
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 Alice {};
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((ConceptA)(ConceptB), Alice);
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