Then he should program in Java.I think Sebastiani wants the kind of pointer-like object references that exist in Java and co.
No. Just... no. God, no! No amount of jury rigging will protect you from idiocy. Sorry, but we are discussing C++ not some magic language that disallows all forms of programmer errors. The code, and offering, provided by Sebastiani will not work to check against a null reference because, strangely, as iMalc said, there is no such thing. The only thing that the Sebastiani offering will provide is a check against his offering which would have to be returned specifically--returning it by accident would be an even bigger issue.undefined!!!
that's the purpose and intent of the OP (at least it was my purpose)
how do i check that "ref" is a valid or invalid reference?
we have this convention of NULL pointer being invalid (not a bulletproof way though, but that's C++, and programmers know)
how we check for above "ref" being valid or invalid?
i has the same situation in my project, and it is giving me nightmares! >_<
This offering, indeed any offering that subverts reference logic, will not help you debug a program. It can't help you find and correct programmer errors. There are however generations of tools that will help you debug a program... use them. (In your case a heavily modified form of new/new/delete/delete/malloc/realloc/calloc/free/etc. and something very similar to 'assert' would be a huge help.)what if i got an object by reference, which was not a local object, which was heap allocated one, but some how, in difficult to follow code, the object is deleted, and all i have is the reference, how to check is it valid?