|
// Functional.h
// Author: Zeeshan Amjad
//
// Some Basic function for template meta programming
//
#ifndef _FUNCTIONAL_H
#define _FUNCTIONAL_H
// return the value of first parameter
template <int u, int v>
struct Value
{
enum { value = u };
};
// add two numbers.
// If second value is missing then return the first value
template <int u, int v = 0>
struct Add
{
enum { value = u + v };
};
// subtract one number from another
// If second value is missing then return the first value
template <int u, int v = 0>
struct Subtract
{
enum { value = u - v };
};
// subtract one number from another
// If second value is missing then return the first value
template <int u, int v = 1>
struct Multiply
{
enum { value = u * v };
};
// divide one number by another
// If second value is missing then return the first value
template <int u, int v = 1>
struct Divide
{
enum { value = u / v };
};
// Modulo operator
template <int u, int v>
struct Mod
{
enum { value = u % v };
};
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.