Pedia Pedia - 1 year ago 103
C++ Question

What does "return {}" statement mean in C++11?

What does the statement

return {};

in C++11 indicate, and when to use it instead of (say)

return NULL;


return nullptr;

Answer Source

this is probably confusing:

int foo()
  return {};   // honestly, just return 0 - it's clearer

This is probably not:

SomeObjectWithADefaultConstructor foo()
  return {};
  // equivalent to return SomeObjectWithADefaultConstructor {};
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download