digitalmars.D.learn - private template members
- hunt0r (19/19) May 01 2011 hi,
- Dmitry Olshansky (9/28) May 01 2011 It's not clear if you are calling it from separate module or from the
- hunt0r (23/23) May 01 2011 I was calling it from another module:
- Dmitry Olshansky (6/29) May 01 2011 Then it's definitely a bug, it might be a duplicate report but it I
- Mike Wey (4/32) May 01 2011 Probably this one: http://d.puremagic.com/issues/show_bug.cgi?id=2775
hi, It seems that template members of a class are always public. having a class like: class Test { private: int x; template test(T) { void test(T t) {x= 100;} } public: int getX() {return x;} } and calling: Test t = new Test; t.test(); prints 100 instead of saying that the member test is not accessable. Is it not possible to get private template members with D?
May 01 2011
On 01.05.2011 13:37, hunt0r wrote:hi, It seems that template members of a class are always public. having a class like: class Test { private: int x; template test(T) { void test(T t) {x= 100;} } public: int getX() {return x;} } and calling: Test t = new Test; t.test(); prints 100 instead of saying that the member test is not accessable. Is it not possible to get private template members with D?It's not clear if you are calling it from separate module or from the same one. The access protection in D is module level, meaning you can access private members of the class in the same module. There are some known bugs about it: http://d.puremagic.com/issues/show_bug.cgi?id=3108 <http://d.puremagic.com/issues/show_bug.cgi?id=314> -- Dmitry Olshansky
May 01 2011
I was calling it from another module: in file Test.d: class Test { private: int x; void testNonTemplate() { } template test() { void test() {x= 100;} } public: int getX() {return x;} } In file main.d: import Test; Test t = new Test; t.test(); /*ok*/ t.testNonTemplate(); /*error*/ writeln(t.getX()); /* prints 100 */ I am using dmd 2.052
May 01 2011
On 01.05.2011 16:38, hunt0r wrote:I was calling it from another module: in file Test.d: class Test { private: int x; void testNonTemplate() { } template test() { void test() {x= 100;} } public: int getX() {return x;} } In file main.d: import Test; Test t = new Test; t.test(); /*ok*/ t.testNonTemplate(); /*error*/ writeln(t.getX()); /* prints 100 */ I am using dmd 2.052Then it's definitely a bug, it might be a duplicate report but it I suggest to file it anyway. It sill fails on my almost newest DMD from github. -- Dmitry Olshansky
May 01 2011
On 05/01/2011 03:15 PM, Dmitry Olshansky wrote:On 01.05.2011 16:38, hunt0r wrote:Probably this one: http://d.puremagic.com/issues/show_bug.cgi?id=2775 -- Mike WeyI was calling it from another module: in file Test.d: class Test { private: int x; void testNonTemplate() { } template test() { void test() {x= 100;} } public: int getX() {return x;} } In file main.d: import Test; Test t = new Test; t.test(); /*ok*/ t.testNonTemplate(); /*error*/ writeln(t.getX()); /* prints 100 */ I am using dmd 2.052Then it's definitely a bug, it might be a duplicate report but it I suggest to file it anyway. It sill fails on my almost newest DMD from github.
May 01 2011