P
Peter Oliphant
Is it possible to have a constructor REFUSE to be constructed? That is, can
one within a constructor check to see if I really want to be constructed,
and return a nullptr instead of a valid object address when a construction
is attempted? Note that 'in the old days', a call to malloc( ) would return
'null' if it couldn't make the allocation for some reason. I'm wondering if
this capability has been preserved in 'gcnew'?
Immediately I can see why this wouldn't be possible if you allow stack
semantics. But I also have noticed that I can't create arrays in stack
semantics (the elements can be objects, but the array must be instantiated
as a pointer). Thus, such restrictions, not allowing stack semantics for
some cases, is not without its precedence...
Not really anything to do with my projects, just a thought that came to
mind...
[==P==]
one within a constructor check to see if I really want to be constructed,
and return a nullptr instead of a valid object address when a construction
is attempted? Note that 'in the old days', a call to malloc( ) would return
'null' if it couldn't make the allocation for some reason. I'm wondering if
this capability has been preserved in 'gcnew'?
Immediately I can see why this wouldn't be possible if you allow stack
semantics. But I also have noticed that I can't create arrays in stack
semantics (the elements can be objects, but the array must be instantiated
as a pointer). Thus, such restrictions, not allowing stack semantics for
some cases, is not without its precedence...
Not really anything to do with my projects, just a thought that came to
mind...
[==P==]