Reputation: 13575
Any difference between (T)value
and T(value)
? For example (float)3.14
and float(3.14)
. Which is faster or better?
Upvotes: 2
Views: 140
Reputation: 792787
They have exactly the same effect and meaning:
ISO/IEC 14882:2011 5.2.3 Explicit type conversion (functional notation):
A simple-type-specifier (7.1.6.2) or typename-specifier (14.6) followed by a parenthesized expression-list constructs a value of the specified type given the expression list. If the expression list is a single expression, the type conversion expression is equivalent (in definedness, and if defined in meaning) to the corresponding cast expression (5.4).
5.4 is "Explicit type conversion (cast notation)", i.e. (T) cast-expression.
Upvotes: 6