Bob Hairgrove said:
Think: "apples and oranges" ... do you really want to compare them?
Well, it's a little bit more complicated:
ptr< int const > p = get_ptr( ); // get_ptr( ) returns ptr< int > which is cast to ptr< int const > via a conversion operator;
p == get_ptr( ); // return value is of type ptr< int > and cannot be comapred to ptr< int const > "out of the box" since conforming
compilers may not take into account any conversions when making the list of callable funcions;
I'd also like to mention that I find it useful to design some templates so that they may be specialized for const types, e.g.:
ptr< int const > - this is a pointer to a constant of type integer; the pointer object may or may not be changed to point to another
constant of type integer, but the pointee may not be changed;
ptr< int > - this is a pointer to an integer; the pointee may be changed but the pointer object may or may not be changed depending
on its const-ness;