5

I've been watching lots of CppCon lectures and I've noticed that Bjarne and Herb both initialize things like this std::unique_ptr<foo>{bar} instead of std::unique_ptr<foo>(bar).

Is there a difference between them that could make them prefer the former?

Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212
ar1a
  • 374
  • 3
  • 10
  • 4
    List initialization does not allow narrowing (§iso.8.5.4). More explanations here: http://stackoverflow.com/questions/18222926/why-is-list-initialization-using-curly-braces-better-than-the-alternatives – LookAheadAtYourTypes May 14 '16 at 07:23

0 Answers0