CPP 1.2 NO IDEA Avatar
  1. OMG Issue

CPP12 — Initialized T_var?

  • Key: CPP12-15
  • Legacy Issue Number: 5578
  • Status: closed  
  • Source: Triodia Technologies Pty Ltd ( Michi Henning)
  • Summary:

    a discussion in comp.object.corba pointed out the difficulty
    of testing whether a T_var has been initialized. There is
    no _is_null() member function or some such. As a result,
    calling operator->() appears to be the only way to test
    whether a T_var is initialized:

    if (T_var.operator->())
    // It's initialized...

    Not exactly elegant, but workable. However, the following
    words in the spec get in the way:

    "The overloaded operator-> returns the T* held by the T_var,
    but retains ownership of it. Compliant applications may not
    call this function unless the T_var has been initialized with a
    valid non-null T* or T_var."

    These words forbid me to call operator->() until after the
    T_var has been initialized, meaning that there is no portable
    and compliant way to test whether a T_var is nil. I think
    what was meant here is that

    "Compliant applications may not *dereference the return value
    of this function* unless the T_var has been initialized with a
    valid non-null T* or T_var."

    BTW – using operator->() to test for null is a bit obscure.
    We could add a _is_null() member to T_var for this. But,
    given the versioning confustion we'd cause and the fact
    that adding the member provides only marginal benefit,
    I think it may be better to leave things as they are. (But
    we should fix the description of operator->(), of course.)

  • Reported: CPP 1.1 — Tue, 20 Aug 2002 04:00 GMT
  • Disposition: Resolved — CPP 1.2
  • Disposition Summary:

    see above

  • Updated: Fri, 6 Mar 2015 20:57 GMT