Skip to content

Instantly share code, notes, and snippets.

@wallstop
Created September 14, 2014 07:21
Show Gist options
  • Save wallstop/d36133b6c3ef429795d7 to your computer and use it in GitHub Desktop.
Save wallstop/d36133b6c3ef429795d7 to your computer and use it in GitHub Desktop.
void doTheThing(const SomeEnum& enum)
{
const int bindedVariable =
[&]()
{
switch(enum)
{
case SOME_ENUM_VAL_1:
return 200;
case SOME_ENUM_VAL_2;
return 400;
default:
return 600;
}
}();
// Do other stuff
}
void doTheThingTwo(bool testCondition)
{
const MemoryIntensiveObject myIntensiveInstance =
[&]()
{
if(testCondition)
return std::move(MemoryIntensiveObject(paramSet1));
else
return std::move(MemoryIntensiveObject(paramSet2));
}();
// Do other stuff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment