Click here to Skip to main content
12,699,029 members (23,612 online)
Click here to Skip to main content


23 bookmarked

Template Meta Programming and Number Theory: Part 2

, 24 Aug 2007 CPOL
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
Software Developer (Senior) Bloomberg LP
United States United States
Working as a Sr C++ Developer at Bloomberg LP

You may also be interested in...

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