In this code (ready to compile):
#include "stdafx.h"
#include <iostream>
#include <sstream>
using std::cout;
template<class T, int first, int second>
T make()
{
T result = T();
std::stringstream interpreter;
interpreter << first << '.' << second;
interpreter >> result;
return result;
}
template<int first, int second, class T = double>
struct Make
{
typedef T value_type;
static value_type value;
};
template<int first, int second, class T>
T Make<first,second,T>::value = make<T,first,second>();
template<int first, int second>
struct Real
{
typedef double type;
static type value;
};
template<int first, int second>
typename Real<first,second>::type typename Real<first,second>::value = typename Make<first,second>::value;
int _tmain(int argc, _TCHAR* argv[])
{
//cout << Make<1,2>::value << '\n';//UNCOMMENT THIS AND SEE WHAT I MEAN
cout << Real<1,2>::value;
return 0;
}
Please see the comment 4 lines above.