[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] code completion & C++11
|
Hi guys,
I have some issues with code completion in C++ and nested classes, and I guess it has to do with C++11. The latter has changed how nested classes have access to private/protected declarations in the nesting class.
I have attached a test case that produces some weird results. Before I issue a bug report I wanted to know whether I'm just too stupid to get things right.
bye Michi
/*
* test.hpp
*
* Created on: 7 Feb 2013
* Author: michi
*/
#ifndef TEST_HPP_
#define TEST_HPP_
class A {
private:
class Private {
public:
static int i;
protected:
static int j;
};
protected:
class Protected {
public:
static int publicInt;
protected:
static int protectedInt;
private:
static Private privateClass;
};
public:
class Public {
public:
static int publicInt;
static Protected publicProtectedClass; // code-completion offers protected class (since C++11 allowed, but in this public code path not sensible)
protected:
static Private protectedPrivateClass; // code-completion offers private class (since C++11 allowed, again not sensible)
};
class Public1 : protected Protected {
};
class Public2 : private Protected {
};
class Public3 : public Protected {
};
class Public4 : public Public {
public:
static int p4;
};
};
#endif /* TEST_HPP_ */
/*
* test.cpp
*
* Created on: 8 Feb 2013
* Author: michi
*/
#include "test.hpp"
void
test() {
A::Private priv; // code-completion offers private nested class - compile error
A::Protected prot; // code-completion offers protected nested class - compile error
A::Protected prot = A::Public::publicProtectedClass; // this is a declaration error in the header - compile error
A::Public1 pub1; // correct
A::Public2 pub2; // correct
// A::Public1:: // no code-completion - correct
int pub3 = A::Public3::publicInt; // offers only publicInt - correct
int pub4 = A::Public4::publicInt; // correct
int pub5 = A::Public4::p4; // correct
A::Protected pub6 = A::Public4::publicProtectedClass; // code-completion allowes this - compile error
}