Small feature request
Kevin Bealer
kevinbealer at gmail.com
Sat Mar 29 11:17:40 PDT 2008
Koroskin Denis Wrote:
> Look at this class.
>
> class Buffer
> {
> private int bufferSize = 4096;
> private void[bufferSize.init] buffer = void;
> }
>
> What's the capacity of buffer upon object construction?
>
> I expect that buffer.length == 4096, since bufferSize == 4096, but get
> buffer.length == 0, since bufferSize.init == int.init.
> It works not as expected and confuses a little. Do I have any chanse this
> will be fixed anytime, or is it intended?
I think this is intended, but you can do this:
class Buffer {
typedef int BufSize_t = 4096;
BufSize_t bufsize;
char[BufSize_t.init] buffer;
};
The code in both cases seems confusing, since you could just use:
class Buffer {
char[4096] buffer;
}
It's a static buffer so the size can't change in any case.
Kevin
More information about the Digitalmars-d
mailing list