Advertisement Jump to content
Sign in to follow this  
dkrusu

Initializing array in function call

This topic is 1804 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Any chance of allowing a initialization list to be used in a function call?

void test(array<string> &in); // Function definition

test({"string1", "string2"});

Or something like:

test(array<string>{"string1", "string2"});

- dave

Edited by dkrusu

Share this post


Link to post
Share on other sites
Advertisement

I'm thinking about attempting to implement this myself. Before I do I'd like to know how you would prefer the syntax to be. I would assume:

func(array<string>{"asd", "asd"});

Any hints or things to keep in mind when working on this?

 

Thanks,

-dave

Share this post


Link to post
Share on other sites

I was planning on using the following syntax, though it is not set in stone yet:

 

// Explicitly give the type of the initialization list
func( array<string> = {"asd", "asd"} );

 

and eventually

 

// Implicitly determine the type of initialization list based on what it is used for
func( {"asd", "asd"} );

 

The latter is much more difficult to implement, and I'll probably hold off on it for a while.

 

It's quite possible that I implement the first variant already for release 2.28.2 as I'm going to be working on the initialization list implementation anyway. I suggest you wait a little, unless you're impatient and wish to get started immediately :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!