mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Updated T.68 example
This commit is contained in:
parent
520ac9c695
commit
3c1991b87b
|
@ -18065,9 +18065,9 @@ When `concept`s become widely available such alternatives can be distinguished d
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
void f(T t, U u)
|
void f(T t, U u)
|
||||||
{
|
{
|
||||||
T v1(x); // is v1 a function or a variable?
|
T v1(T(u)); // mistake: oops, v1 is a function not a variable
|
||||||
T v2 {x}; // variable
|
T v2{u}; // clear: obviously a variable
|
||||||
auto x = T(u); // construction or cast?
|
auto x = T(u); // unclear: construction or cast?
|
||||||
}
|
}
|
||||||
|
|
||||||
f(1, "asdf"); // bad: cast from const char* to int
|
f(1, "asdf"); // bad: cast from const char* to int
|
||||||
|
|
Loading…
Reference in New Issue
Block a user