Click here to Skip to main content
13,345,954 members (56,758 online)
Click here to Skip to main content


23 bookmarked
Posted 24 Aug 2007

Template Meta Programming and Number Theory: Part 2

, 24 Aug 2007
Using C++ language constructs to introduce abstraction layers
// Control.h
// Author: Zeeshan Amjad
// Contains the control structure of meta program

#ifndef _CONTROL_H
#define _CONTROL_H

#include "functional.h"

template <int Start, int End, int Exp = 1, 
	template <int u, int v> class ExpOperator = Add,
	template <int u, int v> class Operator = Add,
	template<int u, int v> class BiFun = Value>
struct ForLoop
	enum { value = Operator<BiFun<Start, End>::value, 
		ForLoop<ExpOperator<Start, Exp>::value, End, Exp, ExpOperator, Operator, BiFun>::value>::value };

template <int End, int Exp, 
	template <int u, int v> class ExpOperator,
	template <int u, int v> class Operator,
	template<int u, int v> class BiFun>
struct ForLoop<End, End, Exp, ExpOperator, Operator, BiFun>
	enum { value = BiFun<End, End>::value };


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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Zeeshan Amjad
Team Leader American Institute for Research
United States United States
Working as a Team leader in American Institute for Research

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 24 Aug 2007
Article Copyright 2007 by Zeeshan Amjad
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid