home bbs files messages ]

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 32,940 of 33,346   
   red floyd to DeMarcus   
   Re: Can I overload with unused arguments   
   19 Mar 13 17:11:47   
   
   From: no.spam.here@its.invalid   
      
   On 3/19/2013 12:41 PM, DeMarcus wrote:   
   >]redacted]   
   > I have a class that takes a handle and a function with   
   > how to deallocate the handle, like this.   
   >   
   > class HandleHolder   
   > {   
   > public:   
   >    HandleHolder( int handle, std::function deallocator );   
   > };   
   >   
   > I /can/ use it like this.   
   >   
   > HandleHolder myHandleHolder( someHandle, nullptr );   
   >   
   > but I want to find a way to avoid using nullptr here since that forces a   
   > documentation lookup what argument two actually is. If I instead write   
   > something like:   
   >   
   > HandleHolder myHandleHolder( someHandle, NO_DEALLOCATION );   
   >   
   > then it's much more clear what's going on and I don't need to check the   
   > documentation. If overloading the constructor so I can use:   
      
   namespace {   
       const std::function NO_DEALLOCATION = nullptr;   
   }   
      
   or, if you'd rather use the preprocessor:   
      
   #define NO_DEALLOCATION nullptr   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca