stdcxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dipak Bapatla <deepak_bo...@sbcglobal.net>
Subject Re: Errors compiling examples - Sun studio 11
Date Tue, 14 Feb 2006 20:52:06 GMT
Actually I tried a test case with using string which should use templates and it works fine.
Anyhow, I compiled the code below and it compiles fine.
   
  thanks,
  Dipak

Martin Sebor <sebor@roguewave.com> wrote:
  Dipak Bapatla wrote:
> I have changed the code as follows in the two definitions in _tree.h to
> get the examples to compile.
> const_iterator _C_make_iter (const _C_link_t __node) const {
> return const_iterator (*this, _C_tree_citer (__node));
> }
> 
> to 
> 
> const_iterator _C_make_iter (_C_link_t __node) const {
> return const_iterator (*this, _C_tree_citer (__node));
> }
> 
> Removed the const from the parameter type. 

Okay, I think we're getting somewhere. I missed this in the error
message since it expands typedefs but the const is pointless there
since it doesn't do what I suspect the author thought it did (i.e.,
apply to the object type rather than to the pointer).

> 
> It is weird that the compiler complained about the code because I have
> the test program below and it works fine as expected.

The bug is probably more subtle than that. Your program doesn't
involve templates. Does the more complicated test case below
compile?

Martin

template struct A { typedef T* P; };

template 
struct B {
typedef typename A::P P;

void foo (P) { }
void foo (const P) const { }

void bar () { foo ((P)0); }
void bar () const { foo ((P)0); }
};

template 
struct C {
B b;

void bar () { b.bar (); }
void bar () const { b.bar (); }
};

int main () {
C c;
c.bar ();

const C d = C();
d.bar ();
}
  


Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message