Swarm-NG  1.1
choose< T, N, MAXN, B, P > Struct Template Reference

Template object function to choose the appropriate instantiation of a function at compile time. More...

#include <helpers.hpp>

Detailed Description

template<template< int > class T, int N, int MAXN, class B, class P>
struct choose< T, N, MAXN, B, P >

Template object function to choose the appropriate instantiation of a function at compile time.

Suppose that you define T as:

template<int N> struct T {
B choose(P p) {
// do something with p
return B( ... );
}
}
and you want to instantiate T for a finite set of values of 
N like 1,2,3,4. and you want to call the appropriate T
at runtime based on n that is provided at runtime.
You will write:

B b = choose< T, 1, 4, B, P>( n, p );

This will try to instantiate T for values 1 to 4 and calls
T::choose with p for appropriate value of n at runtime.
Note that if n is not in range then it returns B().

Definition at line 98 of file helpers.hpp.


The documentation for this struct was generated from the following file: