C++ Uniform Unitialisation
Why not just use the classic int x = 1; and call it a day? - Benefits & Pitfalls
- Consistent syntax
- does not allow narrowing conversions.
But
- variable declared with auto uses brace initialization, its type could be deduced to std::initializer_list
- using std::vectors v(5, 0) != v{5, 0};
- when there’s an overloading constructor that declares its parameter of type std::initializer_list
Written on December 17, 2022, Last update on February 23, 2023
c++
c++-syntax