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.

Reply via email to