5

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.

Zack Stewart
  • 327
  • 1
  • 3
  • 9
  • When you say "C++10" do you mean VS2010 and when you say "C++12" do you mean VS2013? – David G Jun 12 '14 at 20:05
  • Yes, is that not the correct versions? Going from VS2010 to 2013. – Zack Stewart Jun 12 '14 at 20:06
  • 2
    Well to be unambiguous you should not do C++10/C++12 as one might think those are different C++ standards. In the title just use VS2010 and VS2013. – David G Jun 12 '14 at 20:08
  • Answer marked as duplicate is correct. Thank you all. – Zack Stewart Jun 12 '14 at 20:16
  • 1
    A general advice: try compiling your code with gcc and/or clang to get human-readable error messages. Clang is especially good, [here](http://i.imgur.com/okvGwKK.png)'s what it prints for your code. Amazing, no? – n. m. could be an AI Jun 12 '14 at 20:23
  • Visual Studio is an IDE, containing just one of many C++ implementations. C++ is a programming language. They both have different versions that must not be confused or mixed up. – Lightness Races in Orbit Jun 12 '14 at 22:02

0 Answers0