Group Concept Checking
Macros for the concept checking system in SeqAn.

Grouped Macros Overview

SEQAN_CONCEPT(name, params)
Defines a new concept.
SEQAN_CONCEPT_ASSERT((concept))
Perform a concept check.
template<> // required, even if name has no template arguments SEQAN_CONCEPT_IMPL((name), implementedConcepts)
Defines which concepts a model fulfills.
SEQAN_CONCEPT_REFINE(name, params, refinedConcepts)
Defines a new concept as a refinement of existing concepts.
SEQAN_CONCEPT_USAGE(name)
Defines valid expressions.

Grouped Function Overview

Detailed Description

SeqAn's concept checking system is copied from Boost. The license for the library is as follows:

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

Grouped Macros Detail

ConceptChecking#SEQAN_CONCEPT

Defined in
<seqan/basic.h>
SEQAN_CONCEPT(name, params)
Defines a new concept.
Parameters
params - Template paramter list in parantheses, e.g. (T) or (T1)(T2). Typically, template parameters are models, i.e. one or multiple classes that should be checked for fulfilling a concept.This is a sequence of the Boost Preprocessor Library, read more.
name - Concept identifier. Non-trivial concepts should have an identifier with a Concept-suffix.
Data Races
Thread safety unknown!
See Also
SEQAN_CONCEPT_USAGE

A concept is implemented as a template struct with name name and arguments params. The concept checking should be part of the struct definition. Associated types should be checked via SEQAN_CONCEPT_ASSERT and valid expressions in a function SEQAN_CONCEPT_USAGE, see below. Variables used in valid expressions should be (private) struct members instead of local variables in member functions (read more.

Examples

SEQAN_CONCEPT(Assignable,(T))
{
    SEQAN_CONCEPT_USAGE(Assignable)
    {
        a = b;              // require assignment operator
        constConstraints(b);
    }
private:
    void constConstraints(const T& x)
    {
        a = x;              // const required for argument to assignment
        ignoreUnusedVariableWarning(x);
    }
private:
    T a;
    T b;
};

SEQAN_CONCEPT(EqualityComparable,(T))
{
    SEQAN_CONCEPT_USAGE(EqualityComparable)
    {
        requireBooleanExpr(a == b);
        requireBooleanExpr(a != b);
    }
private:
    T a, b;
};

ConceptChecking#SEQAN_CONCEPT_ASSERT

Defined in
<seqan/basic.h>
SEQAN_CONCEPT_ASSERT((concept))
Perform a concept check.
Parameters
concept - Concept specialized with a the type that should be checked.
Data Races
Thread safety unknown!
See Also
Is

This macro is a compile-time assertion and requires the concept specialized with the tested types to compile. The check neither consumes memory nor running time. The macro can be used at the beginning of a function or within a struct/class definition. The checked concepts should be as restrictive and generic as possible to on the one hand cover all used functionality and on the other hand not limit the applicability of a function/class.

Examples

typedef typename Value<TContainer>::Type                TValue;
typedef typename Position<TContainer>::Type             TPosition;
typedef typename Difference<TContainer>::Type           TDifference;

SEQAN_CONCEPT_ASSERT((AlphabetConcept<TValue>));
SEQAN_CONCEPT_ASSERT((SignedIntegerConcept<TDifference>));
SEQAN_CONCEPT_ASSERT((UnsignedIntegerConcept<TSize>));

ConceptChecking#SEQAN_CONCEPT_IMPL

Defined in
<seqan/basic.h>
template<> // required, even if name has no template arguments SEQAN_CONCEPT_IMPL((name), implementedConcepts)
Defines which concepts a model fulfills.
Parameters
implementedConcepts - Identifiers of concepts that are fulfilled by the model. This is a sequence of the Boost Preprocessor Library, read more.
name - Model type, i.e. an identifier or an identifier with template arguments.
Data Races
Thread safety unknown!

template<typename T, int I> SEQAN_CONCEPT_IMPL((name<T,I>), implementedConcepts)

The metafunction Is can be used to determine whether a class models (fulfills) a concepts. A model of a concept must pass the concept check via SEQAN_CONCEPT_ASSERT.

Examples

template <typename TValue, typename TSpec>
SEQAN_CONCEPT_IMPL((String<TValue, TSpec>), (StringConcept));

ConceptChecking#SEQAN_CONCEPT_REFINE

Defined in
<seqan/basic.h>
SEQAN_CONCEPT_REFINE(name, params, refinedConcepts)
Defines a new concept as a refinement of existing concepts.
Parameters
params - Template parameter list in parantheses, e.g. (T) or (T1)(T2). Typically, template parameters are models, i.e. one or multiple classes that should be checked for fulfilling a concept.This is a sequence of the Boost Preprocessor Library, read more.
name - Concept identifier. Non-trivial concepts should have an identifier with a Concept-suffix.
refinedConcepts - Identifiers of concepts that are refined by the new concept.Refined concepts are implicitly integrated into the requirements of the new concept.This is a sequence of the Boost Preprocessor Library, read more
Data Races
Thread safety unknown!
See Also
SEQAN_CONCEPT_USAGE

A concept is implemented as a template struct with name name and arguments params. The struct inherits all refined concept structs. The concept checking should be part of the struct definition. For more information, see SEQAN_CONCEPT.

Examples

SEQAN_CONCEPT_REFINE(AlphabetConcept, (TValue), (Assignable)(DefaultConstructible)(CopyConstructible))
{
    TValue val, val2;

    SEQAN_CONCEPT_USAGE(AlphabetConcept)
    {
        assign(val, val2);
    }
};

ConceptChecking#SEQAN_CONCEPT_USAGE

Defined in
<seqan/basic.h>
SEQAN_CONCEPT_USAGE(name)
Defines valid expressions.
Parameters
name (in) - Identifier of the concept defined with SEQAN_CONCEPT or SEQAN_CONCEPT_REFINE.
Data Races
Thread safety unknown!
See Also
SEQAN_CONCEPT
SEQAN_CONCEPT_REFINE
requireBooleanExpr

This macro should be used to introduce a block (enclosed with curly braces) of valid expressions within a newly defined concept. Valid expressions should test for available functions, operators and the correctness of return types. Use helper functions, e.g. ignoreUnusedVariableWarning, requireBooleanExpr and sameType.

Examples

SEQAN_CONCEPT(EqualityComparable,(T))
{
    SEQAN_CONCEPT_USAGE(EqualityComparable)
    {
        requireBooleanExpr(a == b);
        requireBooleanExpr(a != b);
    }
private:
    T a, b;
};

Grouped Functions Detail

void requireBooleanExpr(x);

Defined in
<seqan/basic.h>
Tests for a boolean expression.

Parameters

x Object that must be convertible to bool

This function can be used to test for functions returning bools, e.g. less operators.

Data Races

Thread safety unknown!

See Also

void sameType(x, y);

Tests for equality of types.

Parameters

x Object of a certain type.
y Object that must be of the same type.

This function can be used to test for the correctness of function return types or the type of an expression in concept tests.

Data Races

Thread safety unknown!

See Also