Skip to content
UPEEC

Uniform Initialization

Brace initialisation `{}` works for all types and forbids narrowing conversions.

Easy
Comments 0

int x{3.7}; is an error (good!); std::vector<int> v{1, 2, 3};. Note vector<int>(3) (three zeros) vs vector<int>{3} (one element 3).

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.