From 3c1991b87bfec6d43e37b25f09662a5591f2a11d Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Thu, 21 Jan 2021 11:46:01 -0800 Subject: [PATCH] Updated T.68 example --- CppCoreGuidelines.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 168974b..b5102c2 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -18058,16 +18058,16 @@ When `concept`s become widely available such alternatives can be distinguished d ##### Reason - `()` is vulnerable to grammar ambiguities. +`()` is vulnerable to grammar ambiguities. ##### Example template void f(T t, U u) { - T v1(x); // is v1 a function or a variable? - T v2 {x}; // variable - auto x = T(u); // construction or cast? + T v1(T(u)); // mistake: oops, v1 is a function not a variable + T v2{u}; // clear: obviously a variable + auto x = T(u); // unclear: construction or cast? } f(1, "asdf"); // bad: cast from const char* to int