Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,006 of 33,346    |
|    DeMarcus to All    |
|    Re: What does null mean?    |
|    27 Apr 13 07:16:00    |
   
   From: demarcus_at_hotmail_com@tellus.orb.dotsrc.org   
      
   >>> Or provide a function that decides what to do in such a case   
   >>>   
   >>> CameraMan cm( GetDefaultAngle() );   
   >>   
   >> This also solves the problem I'm trying to solve, I just suggested the   
   >> symbolic constant for the efficiency.   
   >   
   > Why not:   
   >   
   > inline AnglePtr GetDefaultAngle() { return nullptr; }   
   >   
      
   That's also a solution. In my particular case I wanted to be explicit   
   with the fact that the angle is missing. If the function returns   
   something 'default' then I have to check the documentation what that   
   default value is.   
      
   >>> My general point is that in cases where the meaning of nullptr when used   
   >>> as that isn't obvious, chances are that it's being abused as a special   
   >>> value -- and I don't like special values in general, not just with   
   >>> pointers. (For example, imagine an interface where an integer argument   
   >>> can have meaningful positive values and the negative values -1, -2 and   
   >>> -3 are 'overloaded' to trigger special behavior. Shudder.)   
   >>>   
   >>   
   >> I completely agree. That's actually another investigation I'm working on   
   >> how to solve that situation in a clean way. First time I realized the   
   >> complexity of it was at a time when I had to store measured values.   
   >> Except from a decimal value I also needed to store whether it had been   
   >> measured at all (0.0 is not a good value to store when the value is   
   >> missing), if the signal of the measure was too weak to be within   
   >> operational range, and (after some statistics calculations) if the   
   >> measure was an outlier.   
   >   
   > Use boost::optional
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca