Click to See Complete Forum and Search --> : Why this is legal to write uint_64(x)?


warrener
November 21st, 2007, 04:58 PM
typedef uint_64 Time;

Time x = 123;
Time y = Time(x);

The second line looks like a constructor! But Time is nothing more than a build-in type. Is this legal and why?

laitinen
November 21st, 2007, 05:16 PM
if uint_64 is a valid typedef then the code is legal.

You are only assigning the value of x to y (you are also doing an unecessary explicit cast).

It is just like writing:

int x = 123;
int y = x;

Laitinen

exterminator
November 22nd, 2007, 08:22 AM
This is legal although it does not mean those types have a constructor. This syntax helps in template metaprogramming.