BCS wrote:
Hello Walter,
Andrei suggests making a library type work for this rather than a
language attribute, but it's still an extra thing that will have to be
specified everywhere where used.
I've considered trying to make a template that compile time enforces
Non-null usage but can, with a version flag, be switched to a simple
alias/typedef of the internal type. Near zero overhead and possibly just
as strong a guard.
It's impossible.
You can create a struct that will throw an exception if you use it
uninitialized, or if you try assigning null to it. But the struct cannot
require that it is initialized.
You can add a contract that requires the struct be initialized, and put
the contract and declaration in a template.
- Re: Null references (oh no, not again!) Christopher Wright
- Re: Null references (oh no, not again!) Sean Kelly
- Re: Null references - crash dump on Win The Anh Tran
- Re: Null references (oh no, not again!) Walter Bright
- Re: Null references (oh no, not again!) Andrei Alexandrescu
- Re: Null references (oh no, not again!) Walter Bright
- Re: Null references (oh no, not again!) Sean Kelly
- Re: Null references (oh no, not again!) Walter Bright
- Re: Null references (oh no, not again!) Sean Kelly
- Re: Null references (oh no, not again!) BCS
- Re: Null references (oh no, not again!) Christopher Wright
- Re: Null references (oh no, not again!) Andrei Alexandrescu
- Re: Null references (oh no, not again!) BCS
- Re: Null references (oh no, not again!) Christopher Wright
- Re: Null references (oh no, not again!) BCS
- Re: Null references (oh no, not again!) Christopher Wright
- Re: Null references (oh no, not again!) BCS
- Re: Null references (oh no, not again!) Joel C. Salomon
-