Example #1
0
File: main.cpp Project: CCJY/coliru
Widget createWidget() {
  Builder builder; 
  builder.doSomeBuilding();    
  try {    
    Foo&& foo = builder.a_func_that_may_throw(); 
  } catch (const std::exception& e) {
    // Log that we can't get a Foo and deal with it...
    return Widget(); 
  }
  
  try {
    Bar&& bar = builder.another_func_that_may_throw();
  } catch (const std::exception& e) {
    // Log that we can't get a Bar and deal with it...
    return Widget();
  }
  return Bar(std::move(foo), std::move(bar)); // Want to use rvalue references here but can't!
}