预期的嵌套名称说明符- gcc
expected nested name specifier - gcc
在此代码中:
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: expected nested-name-specifier before 'Best_Fit'|
我正在用gcc 4.6.1编译它
有什么原因不能把Int_Core在单独的头?
这可能一点帮助都没有,但我正在使用以下版本的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.
使用以下命令:
g++ main.cpp -std=c++0x -o main
如果没有-std=c++0x,我会得到错误"expected nested-name-specifier"
相关文章:
- 激励'inline'说明符的真实世界示例?
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 奇怪的结构&GCC&clang(void*返回类型)
- 缺少类型说明符,显式类型为"缺少错误"
- GCC本机矩阵运算库
- PowerPC ppc64le上的Gcc Woverloaded虚拟错误
- gcc和c++17的过载解析失败
- 数据成员SFINAE的C++17测试:gcc vs clang
- GCC对可能有效的代码抛出init list生存期警告
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 除了说明符神秘地破坏编译(Clang,GCC不同意)
- Clang和GCC在转换C++17中非类型模板参数的自动说明符中存在分歧
- GCC 编译类型错误:预期的类型说明符
- 双自动转换函数定义,gcc 错误:错误:预期的类型说明符
- GCC要求此引用声明使用constexpr说明符是否正确
- 在 Visual Studio 中编译 gcc 代码会导致错误 C3646:"__attribute__":未知的覆盖说明符
- 预期的嵌套名称说明符- gcc
- GCC 错误:嵌套名称说明符中使用的类型"claculator"不完整