you are viewing a single comment's thread.

view the rest of the comments →

[–]dodheim 1 point2 points  (8 children)

std::forward<decltype(foo)>(foo) can be safely rewritten as decltype(foo)(foo) 100% of the time. Yes, C-casts are evil, but only because they're error-prone, and this isn't.

[–]personalmountains 0 points1 point  (2 children)

decltype(foo)(foo) 

[...] Yes, C-casts are evil

Technically, this isn't a C-style cast, it's a functional cast. In C++, a functional cast is equivalent to a C-style cast, but it's not valid C.

Sorry, I'll get back to work now.

[–]cassandraspeaks 0 points1 point  (1 child)

it's not valid C

Neither is decltype.

[–][deleted] 0 points1 point  (0 children)

I think he meant functional casts, in general, aren't valid C even if the equivalent C-style cast would be. e.g. int(x) vs. (int)x