|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2004-01-03 22:45:04
"Thorsten Ottosen" <nesotto_at_[hidden]> wrote in message
news:bt7rbb$9dl$1_at_sea.gmane.org...
> "David B. Held" <dheld_at_[hidden]> wrote in message
> news:bt7931$u7g$1_at_sea.gmane.org...
> [...]
> > I think you're misled by the fact that a const member function
> > can only call other const *member functions*. But there is nothing
> > intrinsically wrong with a const member function calling a non-
> > const free function.
>
> I think there is. It's a giant loophole in the general const-correcness
> of all programs.
Then let me try to convince you otherwise with an example:
void log(std::ostream& s, int x);
class foo
{
int x_;
public:
int x(void) const { log(some_log, x_); return x_; }
};
Is this code not const-correct?
> [...]
> 2) in generic code, const T* and const smart_ptr<T> are not equal
> and I will need traits to deal with different syntax
> [...]
As Jeremy points out, they ought not to be equal, either. To see
why, let's level the playing field:
template <typename T>
struct raw_ptr { typedef T* type; };
Now, how do you spell "const T*" with this type generator? Why,
you spell it:
raw_ptr<const T>::type
Doesn't that look suspiciously similar to:
smart_ptr<const T>
?
It looks like you are missing the fact that const smart_ptr<T> is
really analogous to T* const. Now, if you are arguing that T* const
should be the same as T const*, that's an entirely different ball of
wax. But I'm still not convinced.
Dave
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk