lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] zOMG std::max({}, something)


From: Greg Chicares
Subject: [lmi] zOMG std::max({}, something)
Date: Sat, 19 Sep 2020 10:31:14 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

I didn't realize that "{}" acts like a zero of appropriate type here:

 double d = -3.14;
 int i = -17;
-d = std::max(0.0, d);
-i = std::max(0, i);
+d = std::max({}, d);
+i = std::max({}, i);

...and even here:

 std::vector<some_type> v {0,1,2,3,4,5,6,7,8,9,10,11};
-v.assign(12, 0);  // "0", or "0U", "0.0"...as the case may be
+v.assign(12, {}); // a zero of deduced type



reply via email to

[Prev in Thread] Current Thread [Next in Thread]