| Metafunction Switch Metaprogramming switch expression. Switch<TAG, Case>::Type Include Headers seqan/basic.h Parameters
TAG | The case label. Types: int
Case | Cascade of Case tags. Types: Case, NilCase
Return Values The selected type from the Case cascade or NilCase. Examples int switchTest(Nothing const &) { return -1; } int switchTest(False const &) { return 0; } int switchTest(True const &) { return 1; } int switchTest(NilCase const &) { return 2; } template <int X> struct SwitchTest { typedef typename Switch< X, Case<-1, Nothing, Case<0, False, Case<1, True > > > >::Type Type; }; SEQAN_DEFINE_TEST(test_metaprogramming_switch) { typedef typename SwitchTest<-1>::Type T1; typedef typename SwitchTest< 0>::Type T2; typedef typename SwitchTest< 1>::Type T3; typedef typename SwitchTest< 2>::Type T4; std::cout << switchTest(T1()) << std::endl; // => -1 std::cout << switchTest(T2()) << std::endl; // => 0 std::cout << switchTest(T3()) << std::endl; // => 1 std::cout << switchTest(T4()) << std::endl; // => 2 } See Also Case, NilCase SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:12:59