Jump to content
  • Advertisement
Sign in to follow this  
Solokiller

Explicit constructors

This topic is 526 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

It is currently possible to implicitly invoke the constructor of one type to call the constructor of another:

engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f(int value)", asFUNCTION(String_IntConstruct), asCALL_CDECL_OBJLAST);

engine->RegisterObjectBehaviour("string_t", asBEHAVE_CONSTRUCT, "void f(const string& in str)", asFUNCTION(string_t_StrConstruct), asCALL_CDECL_OBJLAST);
string_t str = 0; //Becomes "0"

This is allowed due to implicit constructor usage. Is there any way to make the string constructor explicit so only string( 0 ) will be considered valid, like C++'s explicit constructor syntax?

I don't see any way to specify this for value or reference types at this time.

Share this post


Link to post
Share on other sites
Advertisement

Currently no. 

 

However it is something I plan to add support for in a future release. (I thought I had it documented in my to-do list already, but apparently I had forgotten to).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!