0

In this code:

Int.h:

#include <type_traits>


#include "Best_Fit.h"
template<class Int_T, typename Best_Fit<Int_T>::type Min_Range,typename Best_Fit<Int_T>::type Max_Range>
class Int_Core
{//If I move this class to a separate header I'm getting aforementioned error

};

template<class Int_T, typename Best_Fit<Int_T>::type Min_Range, typename Best_Fit<Int_T>::type Max_Range>
class Int : private Int_Core<Int_T,Min_Range,Max_Range>
{

};

Best_Fit.h:

struct Signed_Type
{
    typedef long long type;
};

struct Unsigned_Type
{
    typedef unsigned long long type;
};

template<bool Cond, class First, class Second>
struct if_
{
    typedef typename First::type type;
};

template<class First, class Second>
struct if_<false,First,Second>
{
    typedef typename Second::type type;
};

template<class Int_T>
struct Best_Fit
{
    typedef typename if_<std::is_signed<Int_T>::value,Signed_Type,Unsigned_Type>::type type;
};  

main.cpp:

#include <iostream>

using namespace std;

#include "Int.h"

int main(int argc, char* argv[])
{
    return 0;
}

Error:

error: expected nested-name-specifier before 'Best_Fit'|  

I'm compiling it with gcc 4.6.1
Any reason for not being able to place Int_Core in separate header?

Mat
  • 202,337
  • 40
  • 393
  • 406
smallB
  • 16,662
  • 33
  • 107
  • 151
  • Most likely you have an issue in the include file. or one of the files it includes. Take a look at that closer then if it doesn't work output the processor out put. – rerun Oct 15 '11 at 14:22

1 Answers1

0

This probably won't help at all, but I'm compiling this fine using the following version of g++:

g++ --version 
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

with the following command:

g++ main.cpp -std=c++0x -o main

Without the -std=c++0x I get the error "expected nested-name-specifier"

tmaric
  • 5,347
  • 4
  • 42
  • 75