dimanche 29 novembre 2015

Idiomatic acronym for a smart pointer

When I write WidgetP, everyone understands that I mean a pointer to Widget. I was using WidgetUP for std::unque_ptr<Widget> and WidgetSP for std::shared_ptr<Widget>. This was all good until I needed to give the client of my class a choice of which smart pointer to use:

template<class Widget>
using WidgetUP = std::unique_ptr<Widget>;
template<class Widget>
using WidgetSP = std::shared_ptr<Widget>;
template<class Widget>
using DefaultWidgetSP = WidgetUP<Widget>; // here SP stands for smart pointer, 
                                          // not shared pointer!

template <class Widget, 
          template <class> class WidgetSP_ = DefaultWidgetSP>
struct MyContainer {
    ... 
};

Now the SP acronym is overloaded: at times it stands for smart pointer and at other times it stands for shared pointer? Is there an idiomatic notation for this case?

Aucun commentaire:

Enregistrer un commentaire