[Development] Some Qt3D feedback

Thiago Macieira thiago.macieira at intel.com
Tue Jun 16 23:06:10 CEST 2015


On Tuesday 16 June 2015 13:35:55 Thiago Macieira wrote:
> On Tuesday 16 June 2015 10:27:15 Matthew Woehlke wrote:
> > Ignoring whether or not to use 'auto', there actually *is* a reason to
> > use the static_cast... it communicates that, yes, you really want back
> > an 'int', even if that means a conversion loss e.g. because your input
> > is a 'double'. (See e.g. '-Wconversion'.)
> 
> For PODs, please use function-style casts.
> 
> 	auto i = int(longValue);
> 
> Of course, you had to type an extra keystroke compared to
> 
> 	int i = int(longValue);

Actually, not for all PODs. Just the integrals and bool. You obviously cannot 
convert a pointer via function-style casting.

And for bool, if you want to save on keystrokes, you can use the double-bang 
operator:

	auto x = !!longValue;

which is two keystrokes and considerably more obfuscated than

	bool x = longValue;
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list