Click here to Skip to main content
12,064,822 members (35,098 online)
Click here to Skip to main content

Stats

25.6K views
156 downloads
22 bookmarked
Posted

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 };
};

#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.

License

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

Share

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
Web03 | 2.8.160204.4 | Last Updated 24 Aug 2007
Article Copyright 2007 by Zeeshan Amjad
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid