September 07, 2007 Re: What is the difference between... | ||||
---|---|---|---|---|
| ||||
OK. Not quite what I was getting at, but still useful, thanks. In that case, what is the difference between: int f(const void * p, int len) and int f(const(void *) p, int len) ? Put another way: what's the difference between "const (...)" with brackets and "const ..." without? What happens when you take the brackets away? What is the difference between const as a parameter storage class, and const as a type modifier? The following really does compile without error: void f(const const(int) p) and I don't understand what the two different versions of "const" are each doing. -----Original Message----- From: digitalmars-d-bounces@puremagic.com [mailto:digitalmars-d-bounces@puremagic.com] On Behalf Of Xinok Sent: 07 September 2007 11:08 To: digitalmars-d@puremagic.com Subject: Re: What is the difference between... > const void* > This can also be read as: > const(void*) > This means that both 'void' and the pointer are const. > > const(void)* > The pointer is mutable, but the data it points to must be const, even though it doesn't know the type of the data. > > Janice Caron wrote: > > What is the difference between: > > > > int f(const void * p, int len) > > > > and > > > > int f(const(void)* p, int len) > > > > ? |
Copyright © 1999-2021 by the D Language Foundation