[asterisk-scf-dev] Changes regarding state replicator keys

David M. Lee dlee at digium.com
Fri Dec 17 06:09:02 UTC 2010


On Dec 16, 2010, at 5:56 PM, Mark Michelson wrote:

> So making the conversion a non-member function is expressly forbidden in the second case. In the first case, the compiler seems a bit...confused. It's certainly possible I messed up the syntax though.

No, I think you're right.  const char* is the proper return type for the function, not char[].  So non-member conversion functions are out of the question.

Options:

0. I still think that just having string keys is the best option.  I worry about what might happen if the key class gets sliced.  Probably not a valid use case (a client using a derived class of K for the key), but there's no easy way to catch those sort of errors.  If there is some class that makes more sense for a key, adding a toString() function to the class shouldn't be onerous.  

1. Require K to have member functions c_str() and size().  std::string fulfills this contract, so it can be used as-is.  It's probably a bit odd for other classes we might want to use for K.

2. Require K to have a member function toString(), which returns a std::string or const std::string&.  We can specialize the template to accept std::string as a type for K.  Might lead to some code duplication between the StateReplicator template and its specialization.

dave
<><


More information about the asterisk-scf-dev mailing list