c++ - Declare array in function call -


right, know possible in c++0x/c++11, , therefore can done in visual studio 2012.

however, running visual studio 2010. want know if @ possible similar to:

void myfunction(int myarray[]) {} 

myfunction({1,2,3});

without inconvenience of having declare array beforehand.

is there workaround way of doing in version of c++ visual studio 2010 uses? or somehow updating compiler visual studio 2010 uses support more c++11 features? or out of options?

edit:

thanks yzt, have been able boost!

here's example code in case else happens in position (i don't seem able use normal array this, std::vector (or indeed stl container), etc fine!):

the function:

void testfunction(std::vector<int> myarray) {     for(std::vector<int>::size_type = 0; < myarray.size(); ++i)     {         std::cout<<myarray[i]<<std::endl;     } } 

calling it:

testfunction(boost::assign::list_of(1)(2)(3));

i'm not sure exact use case, can use boost.assign this. , yes, work in vc10.

as has been posted in comments, 1 can this:

testfunction(boost::assign::list_of(1)(2)(3)); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -