I'll try to make this as short as possible without overloading on code. If you want more of the code, please comment.
I am running into a compiler error with some lines of code relating to templates. This code was written in 2005, but continued to work in Visual Studio 2010. While upgrading to VS2013, it no longer works.
The line with an error is
typedef typename LookupPow<POW - 1>::Evaluate<Pow_impl<ROOT, POW - 1 >> ::Value Next;
seeming to be an issue with the < after Evaluate, the compiler gives
error C2059: syntax error : '<'
It seems to be a complicated way to write a power function such that it evaluates at compile time instead of run-time.
The line is in this block of code
template <int ROOT, int POW>
struct Pow_impl
{
/// <summary>
/// The next recursive type to use to calculate the exponent
/// This will count down from POW to 0 each time multiplying ROOT to the current value
/// </summary>
typedef typename LookupPow<POW - 1>::Evaluate< Pow_impl<ROOT, POW - 1 >> ::Value Next;
/// <summary>
/// Recursively calculate the next exponent
/// POW will recursively count down from the value originally used to 0
/// This effectively multiplies ROOT together POW times
/// </summary>
enum { Value = ROOT * Next::Value };
};
With the Evaluate being defined in
template <int CNT>
struct LookupPow
{
/// <summary>
/// For the base case, just provide the template parameter as the typedef Value
/// </summary>
template <typename T>
struct Evaluate
{
/// <summary>
/// The Evaluate meta-function return value. This matches the template parameter
/// </summary>
typedef T Value;
};
};
There are base case LookupPow templates as well, which I have not included.
Any advice would be incredibly useful.