ecorm / cppwamp

C++ client library for the WAMP protocol.
Boost Software License 1.0
35 stars 9 forks source link

Should Rpc, Procedure, Pub, Topic and friends have converting constructors? #60

Closed ecorm closed 9 years ago

ecorm commented 9 years ago

Should Rpc, Procedure, Pub, Topic and friends have converting constructors? For instance, Rpc has an explicit constructor taking a string for the procedure name. By making the constructor non-explicit, it would make it more convenient to call RPCs.

For example, instead of

session->call(Rpc("foo"), yield);

You could simply do:

session->call("foo", yield);

However, as soon as you need to specify arguments or options, you'd have to use explicit construction:

session->call(Rpc("foo").withArgs({42}), yield);
ecorm commented 9 years ago

I think with C+11 list initialization, you could simply do this:

session->call({"foo"}, yield)

I need to test it out to make sure. If that's indeed the case, then the constructors should stay explicit.

ecorm commented 9 years ago

I tried the above a got a compiler error.

ecorm commented 9 years ago

I'm going ahead and changing these constructors to implicit. This will not break the current API.