Behaviour of const KSharedPtrs

Thiago Macieira thiago.macieira at
Sat Nov 13 01:12:27 GMT 2004

Stefan Teleman wrote:
> Should the following code compile ?

No, but it's because of this:

>    foo.get() = &y;

You're trying to change the value of the returned data. That will never 

I think you meant to write the function as:
            T* const & get() const { return _t; }
            T* & get() { return _t; }

That would allow using get() as you wrote it in main, and would also 
respect the constness of the Foo object.

  Thiago Macieira  -  Registered Linux user #65028
   thiago (AT) macieira (DOT) info
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <>

More information about the kde-core-devel mailing list