Nate,
>You get no benefits at all by adding smart pointers to the interface.
>The user will delete their objects whenever they wish, regardless of
>what the openwire library does ... and if it does so, the openwire
>library will explode as soon as it tries to reference it. That's the
>thing - this is C++ and there is no mechanism to prevent someone from
>coding badly, and adding smart pointers to the API isn't going to change
>that. The user is responsible for both adding and removing referenes to
>its objects. And it's not the job of the openwire lib to worry about
>memory management in the user-domain - it should only be concerned with
>its own memory management.
>In addition, smart pointers are assuming that the object is allocated on
>the heap, as it will do a "delete" when the last reference is removed.
>This is wrong, because the user should be able allocate its objects in
>whatever way makes sense for the application.
>Also, adding smart pointer arguments to all the methods on the api makes
>it complicated and ugly. If the openwire library wants to use smart pointers
>internally, that's fine, but it shouldn't impose the use of smart pointers
>on the user. It's our job to make the user's experience a good one so they
>continue to use ActiveMQ in their applications.
Please define the interfaces that you want to be SP-free!
>It's all about the user and helping them come up to speed and use the api
>as quickly and painlessly as possible. I understand that in these cases
>you're passing a pointer and not copying, but it complicates the user
>interface when the person just wants to pass in a string. They shouldn't
>have to create a string on the heap an then wrap it in a smart pointer to
>just call a function.
Just a quick note, this is not necessary with the current design of accepting
"const char*" and returning p<string>. The user can easily extract the const
char from the SP string if wanted.
>Class Xxx {
> std::string name;
> void setName (const std::string& name) {
> this->name = name;
> }
> const std::string& getName () const {
> return this->name;
> }
>};
Shall we agree on the one above?
Regards,
Mats & David