From: itaj sherman on 23 May 2010 03:48 On Apr 29, 10:03 pm, DeMarcus <use_my_alias_h...(a)hotmail.com> wrote: > Hi, > > In C++0x, is lambda the most proper way to initialize a std::function > with a valid function that does nothing? > > class SomeClass > { > public: > SomeClass() : fnc_([]{}) {} > > private: > std::function<void()> fnc_; > > }; > > Thanks, > Daniel > It might be, depends on the scope of the module I would consider defining an empty function in this module to use as default empty value. void empty_function() {} Because []{} might become like a magic number, only worse: I'm not sure in which cases you could later add: if( fnc_ == []{} ) { DebugTrace( "using empty function" ); } or maybe you would want to change to: void empty_function() { DebugTrace( "empty function" ); } itaj -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
First
|
Prev
|
Pages: 1 2 3 Prev: [ANN] CodeSynthesis XSD 3.3.0 released Next: ideas for data binding? |