[cfe-dev] vector constructors

Jochen Wilhelmy j.wilhelmy at arcor.de
Wed Mar 17 09:08:21 PDT 2010


Hi!

just to capture the current state of c++ style vector support I made a 
little test:

struct Foo
{
     Foo(int) : x() {} // works
     Foo(float f) : x(f) {} // works
     Foo(float4 x) : x(x) {} // works
     Foo() : x(1, 2, 3, 4) {} // error: excess elements in scalar 
initializer

     float4 bar1() {return float4();} // works
     float4 bar2() {return float4(f);} // works
     float4 bar3() {return float4(x);} // works
     float4 bar4() {return float4(1, 2, 3, 4);} // error: function-style 
cast to a builtin type can only take one argument

     float f;
     float4 x;
};

I only checked if the statements compile.

-Jochen




More information about the cfe-dev mailing list