Group Enable-If Functionality
The metafunctions and macros for enabling/disabling of functions.
Grouped Macros Overview
Bind the visibility of a constructor to an expression. |
Bind the visibility of a constructor to an expression. |
Bind the visibility of a function to an expression. |
Bind the visibility of a function to an expression. |
Grouped Metafunction Overview
-
DisableIf<TBool, T = void>::Type
Metafunction to use for conditionally disabling code. -
DisableIf2<BOOL, T = void>::Type
Metafunction to use for conditionally disabling code, bool version. -
EnableIf<TBool, T = void>::Type
Metafunction to use for conditionally enabling code. -
EnableIf2<BOOL, T = void>::Type
Metafunction to use for conditionally enabling code, bool version.
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);
- 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.
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);
- 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.
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);
- 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.
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);
- 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.
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 */) { /* ... */ }