Group Enable-If Functionality
The metafunctions and macros for enabling/disabling of functions.

Grouped Macros Overview

SEQAN_CTOR_DISABLE_IF(TCondition);
Bind the visibility of a constructor to an expression.
SEQAN_CTOR_ENABLE_IF(TCondition);
Bind the visibility of a constructor to an expression.
SEQAN_FUNC_DISABLE_IF(TCondition, TResult);
Bind the visibility of a function to an expression.
SEQAN_FUNC_ENABLE_IF(TCondition, TResult);
Bind the visibility of a function to an expression.

Grouped Metafunction Overview

Detailed Description

The EnableIf metafunctions also support the shortcut to ::Type members as described for the logical metaprogramming metafunctions.

Enable-if is an advanced technique and mostly interesting if you want to extend the SeqAn library with generic algorithms. The average developer does not have to know about this technique..

See Also

Grouped Macros Detail

EnableIfFunctionality#SEQAN_CTOR_DISABLE_IF

Defined in
<seqan/basic.h>
SEQAN_CTOR_DISABLE_IF(TCondition);
Bind the visibility of a constructor to an expression.
Parameters
TCondition - Boolean type, one of True and False or a metafunction returning such a tag type. If False then the constructor is visible, otherwise, it is not.
Data Races
Thread safety unknown!

This macro allows to bind the visibility of a construtor to a boolean expression by using the SFINAE principle for an optional argument with default value. The macro call must be used as the last dummy-argument of a constructor.

To avoid an unused argument warning, call ignoreUnusedVariableWarning(dummy) in the constructor's body.

Important: The constructor to disable must be a function template and TCondition must include at least one template parameter of the function template.

Example

The following shows an example on how to properly use SEQAN_CTOR_DISABLE_IF as the last argument to the constructor and suppressing the unused variable warning for the dummy parameter.

    template <typename T>
    EnableIfExample(T const & n, SEQAN_CTOR_DISABLE_IF(Is<IntegerConcept<T> >)) :
        num(0)
    {
        ignoreUnusedVariableWarning(dummy);
    }

EnableIfFunctionality#SEQAN_CTOR_ENABLE_IF

Defined in
<seqan/basic.h>
SEQAN_CTOR_ENABLE_IF(TCondition);
Bind the visibility of a constructor to an expression.
Parameters
TCondition - Boolean type, one of True and False or a metafunction returning such a tag type. If True then the constructor is visible, otherwise, it is not.
Data Races
Thread safety unknown!

This macro allows to bind the visibility of a construtor to a boolean expression by using the SFINAE principle for an optional argument with default value. The macro call must be used as the last dummy-argument of a constructor.

To avoid an unused argument warning, call ignoreUnusedVariableWarning(dummy) in the constructor's body.

Important: The constructor to enable must be a function template and TCondition must include at least one template parameter of the function template.

Example

The following shows an example on how to properly use SEQAN_CTOR_ENABLE_IF as the last argument to the constructor and suppressing the unused variable warning for the dummy parameter.

    template <typename T>
    EnableIfExample(T const & n, SEQAN_CTOR_ENABLE_IF(Is<IntegerConcept<T> >)) :
        num(0)
    {
        ignoreUnusedVariableWarning(dummy);
    }

EnableIfFunctionality#SEQAN_FUNC_DISABLE_IF

Defined in
<seqan/basic.h>
SEQAN_FUNC_DISABLE_IF(TCondition, TResult);
Bind the visibility of a function to an expression.
Parameters
TCondition - Boolean type, one of True and False or a metafunction returning such a tag type. If False then the function is visible, otherwise, it is not.
TResult - The type that the function should have as the return type in case it is enabled.
Data Races
Thread safety unknown!

This macro allows to bind the visibility of a construtor to a boolean expression by using the SFINAE principle for an optional argument with default value. The macro call must occur as the return type definition of the function.

To avoid an unused argument warning, call ignoreUnusedVariableWarning(dummy) in the constructor's body.

Important: The function to disable must be a function template and TCondition must include at least one template parameter of the function template.

Example

The following shows an example on how to properly use SEQAN_FUNC_DISABLE_IF as the last argument to the constructor and suppressing the unused variable warning for the dummy parameter.

    template <typename T>
    SEQAN_FUNC_DISABLE_IF(Is<IntegerConcept<T> >)
    f(T /* x */)
    { /* ... */}

EnableIfFunctionality#SEQAN_FUNC_ENABLE_IF

Defined in
<seqan/basic.h>
SEQAN_FUNC_ENABLE_IF(TCondition, TResult);
Bind the visibility of a function to an expression.
Parameters
TCondition - Boolean type, one of True and False or a metafunction returning such a tag type. If True then the function is visible, otherwise, it is not.
TResult - The type that the function should have as the return type in case it is enabled.
Data Races
Thread safety unknown!

This macro allows to bind the visibility of a construtor to a boolean expression by using the SFINAE principle for an optional argument with default value. The macro call must occur as the return type definition of the function.

To avoid an unused argument warning, call ignoreUnusedVariableWarning(dummy) in the constructor's body.

Important: The function to enable must be a function template and TCondition must include at least one template parameter of the function template.

Example

The following shows an example on how to properly use SEQAN_FUNC_ENABLE_IF as the last argument to the constructor and suppressing the unused variable warning for the dummy parameter.

    template <typename T>
    SEQAN_FUNC_ENABLE_IF(Is<IntegerConcept<T> >)
    f(T /* x */)
    { /* ... */ }

Grouped Metafunctions Detail

DisableIf<TBool, T = void>::Type

Defined in
<seqan/basic.h>
Metafunction to use for conditionally disabling code.

Template Parameters

TBool The Tag True or False to use for enabling/disabling.
T Dummy, do not set.

Returns

Type Set to T. Only defined if TBool is False. This triggers the SFINAE behaviour in C++ which can be used to enable/disable functions.

Do not use directly but use through the enable if/disable if macros.

DisableIf2<BOOL, T = void>::Type

Defined in
<seqan/basic.h>
Deprecated.

Will be renamed to DisableIfC.

Metafunction to use for conditionally disabling code, bool version.

Template Parameters

BOOL The bool constant to evaluate for enabling/disabling.
T Dummy, do not set.

Returns

Type Set to T. Only defined if BOOL is false. This triggers the SFINAE behaviour in C++ which can be used to enable/disable functions.

Do not use directly but use through the enable if/disable if macros.

EnableIf<TBool, T = void>::Type

Defined in
<seqan/basic.h>
Metafunction to use for conditionally enabling code.

Template Parameters

TBool The Tag True or False to use for enabling/disabling.
T Dummy, do not set.

Returns

Type Set to T. Only defined if TBool is True. This triggers the SFINAE behaviour in C++ which can be used to enable/disable functions.

Do not use directly but use through the enable if/disable if macros.

EnableIf2<BOOL, T = void>::Type

Defined in
<seqan/basic.h>
Deprecated.

Will be renamed to EnableIfC.

Metafunction to use for conditionally enabling code, bool version.

Template Parameters

BOOL The bool constant to evaluate for enabling/disabling.
T Dummy, do not set.

Returns

Type Set to T. Only defined if BOOL is true. This triggers the SFINAE behaviour in C++ which can be used to enable/disable functions.

Do not use directly but use through the enable if/disable if macros.