g ++에서 매우 예외적 인 오류가 발생했습니다. 유형 별칭이 비공개임을 주장합니다. 내 코드를 줄일 수 시간 후, 나는 다음과 같은 최소한의 테스트 케이스에 도착했습니다 : g ++ 4.8.2와C++ : Strange "private"오류입니다.
template <typename Dummy>
class Test {
struct CatDog {
static void meow()
{
CrazyHouse::TheCatDog::meow();
}
struct Dog {
static void bark();
};
};
struct CrazyHouse {
using TheCatDog = CatDog;
static void startMadness()
{
TheCatDog::meow();
TheCatDog::Dog::bark();
}
};
public:
static void init()
{
CrazyHouse::startMadness();
}
};
int main()
{
Test<void> t;
t.init();
}
오류 :
test.cpp: In instantiation of 'static void Test<Dummy>::CatDog::meow() [with Dummy = void]':
test.cpp:19:29: required from 'static void Test<Dummy>::CrazyHouse::startMadness() [with Dummy = void]'
test.cpp:27:34: required from 'static void Test<Dummy>::init() [with Dummy = void]'
test.cpp:34:12: required from here
test.cpp:15:33: error: 'using TheCatDog = struct Test<void>::CatDog' is private
using TheCatDog = CatDog;
^
test.cpp:6:41: error: within this context
CrazyHouse::TheCatDog::meow();
^
연타 3.4 동일한 코드를 받아들입니다. 여기서 무슨 일이 일어나고있는 거지, 이건 g ++ 버그 야? 다음의 행동
가 발생하는에서 오류를 중지 : 템플릿 클래스에 반대
- 는, 클래스에
Test
켜기. - 함수에서 명령문을 제거하십시오.
TheCatDog::Dog::bark();
을CatDog::Dog::bark();
으로 변경하십시오.- 클래스를 제거하고 해당 내용을
Test
에 병합합니다. - 클래스를 제거하고 내용을
Test
에 병합하고TheCatDog
별칭을Test
으로 변경합니다.
대체로 그렇습니다. – Shoe