Group Logic Metaprogramming
Logic Metaprogramming operations.

Grouped Metafunction Overview

Detailed Description

This group contains metafunctions for logical operations.

For each boolean operation, there is one metafunction called Operation and one called OperationC (i.e. having a suffix C. The first one works on boolean tag types True and False. The second one takes bool constant parameters.

The metafunctions allow a shortcut using the SFNAE (substitution failure is not an error) feature of the C++ programming language. When passing metafunctions returning True and False in their Type member typedef, you can ommit the ::Type.

Here is an example for this:

    typedef seqan::And<seqan::Or<seqan::True, seqan::False>, seqan::True> TResult;
    printBoolType(TResult());  // => "true"

See Also

Grouped Metafunctions Detail

And<TLhs, TRhs>::Type; And<TLhs, TRhs>::VALUE;

Defined in
<seqan/basic.h>
Metaprograming "and" operatand.

Template Parameters

TLhs The left hand side logical value tag.
TRhs The right hand side logical value tag.

Returns

Type The logical value tag result fand the and operation.
VALUE Shandtcut fand And<TLhs, TRhs>::Type::VALUE.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using And.

    printBoolType(seqan::And<seqan::False, seqan::False>::Type());  // => "false"
    printBoolType(seqan::And<seqan::False, seqan::True >::Type());  // => "true"
    printBoolType(seqan::And<seqan::True,  seqan::False>::Type());  // => "true"
    printBoolType(seqan::And<seqan::True,  seqan::True >::Type());  // => "true"

AndC<LHS, RHS>::Type; AndC<LHS, RHS>::VALUE;

Defined in
<seqan/basic.h>
Metaprograming boolean "and" operator.

Template Parameters

LHS Left hand side bool constant.
RHS Right hand side bool constant.

Returns

Type The logical value tag result for the or operation.
VALUE Shortcut for AndC<LHS, RHS>::Type::VALUE.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using AndC.

    printBoolType(seqan::AndC<false, false>::Type());  // => "false"
    printBoolType(seqan::AndC<false, true >::Type());  // => "true"
    printBoolType(seqan::AndC<true,  false>::Type());  // => "true"
    printBoolType(seqan::AndC<true,  true >::Type());  // => "true"

Eval<VALUE>::Type

Defined in
<seqan/basic.h>
Conversion from bool to tags True and False.

Template Parameters

VALUE A bool to convert to True/False.

Returns

Type The resulting tag, one of True and False.

Examples

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code and achieve the following output:

    printBoolType(seqan::Eval<true>::Type());  // => "true"
    printBoolType(seqan::Eval<false>::Type()); // => "false"

If<TCondition, TResultTrue, TResultFalse>::Type

Defined in
<seqan/basic.h>
Metaprogramming implication.

Template Parameters

TCondition The condition.
TResultTrue Result if TCondition evaluates to True.
TResultFalse Result if TCondition evaluates to False.

Returns

Type The resulting type.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using If.

    printBoolType(seqan::If<seqan::True, seqan::True,  seqan::False>::Type());  // => "true"
    printBoolType(seqan::If<seqan::True, seqan::False, seqan::True >::Type());  // => "false"

If<CONDITION, TResultTrue, TResultFalse>::Type

Defined in
<seqan/basic.h>
Metaprogramming boolean, implication.

Template Parameters

CONDITION The condition, bool.
TResultTrue Result if TCondition evaluates to True.
TResultFalse Result if TCondition evaluates to False.

Returns

Type The resulting type.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using If.

    printBoolType(seqan::If<seqan::True, seqan::True,  seqan::False>::Type());  // => "true"
    printBoolType(seqan::If<seqan::True, seqan::False, seqan::True >::Type());  // => "false"

Not<TBool>::Type; Not<TBool>::VALUE;

Defined in
<seqan/basic.h>
Metaprograming boolean "not" operator.

Template Parameters

TBool The tag to negate.

Returns

Type The inverted TBool.
VALUE Shortcut for Not<TBool>::Type::VALUE.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using Not.

    printBoolType(seqan::Not<seqan::False>::Type());  // => "true"
    printBoolType(seqan::Not<seqan::True>::Type());   // => "false"

NotC<BOOL>::Type; NotC<BOOL>::VALUE;

Defined in
<seqan/basic.h>
Metaprograming boolean "not" operator for values.

Template Parameters

BOOL The bool value to negate.

Returns

Type The corresponding Tag for !BOOL (True/False).
VALUE Shortcut for NotC<BOOL>::Type::VALUE.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using NotC.

    printBoolType(seqan::NotC<false>::Type());  // => "true"
    printBoolType(seqan::NotC<true>::Type());   // => "false"

Or<TLhs, TRhs>::Type; Or<TLhs, TRhs>::VALUE;

Defined in
<seqan/basic.h>
Metaprograming "or" operator.

Template Parameters

TLhs The left hand side logical value tag.
TRhs The right hand side logical value tag.

Returns

Type The logical value tag result for the or operation.
VALUE Shortcut for Or<TLhs, TRhs>::Type::VALUE.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using Or.

    printBoolType(seqan::Or<seqan::False, seqan::False>::Type());  // => "false"
    printBoolType(seqan::Or<seqan::False, seqan::True >::Type());  // => "true"
    printBoolType(seqan::Or<seqan::True,  seqan::False>::Type());  // => "true"
    printBoolType(seqan::Or<seqan::True,  seqan::True >::Type());  // => "true"

OrC<LHS, RHS>::Type; OrC<LHS, RHS>::VALUE;

Defined in
<seqan/basic.h>
Metaprograming boolean "or" operator.

Template Parameters

LHS Left hand side bool constant.
RHS Right hand side bool constant.

Returns

Type The logical value tag result for the or operation.
VALUE Shortcut for OrC<LHS, RHS>::Type::VALUE.

Example

We define the following two helper functions.

void printBoolType(seqan::True const & /*tag*/)
{
    std::cout << "true" << std::endl;
}

void printBoolType(seqan::False const & /*tag*/)
{
    std::cout << "false" << std::endl;
}

Now, we can write the following code using OrC.

    printBoolType(seqan::OrC<false, false>::Type());  // => "false"
    printBoolType(seqan::OrC<false, true >::Type());  // => "true"
    printBoolType(seqan::OrC<true,  false>::Type());  // => "true"
    printBoolType(seqan::OrC<true,  true >::Type());  // => "true"