What's your convention for typedef'ing shared_ptr?

后端 未结 16 1679
北恋
北恋 2020-12-13 00:10

I\'m flip-flopping between naming conventions for typedef\'ing the boost::shared_ptr template. For example:

typedef boost::shared_ptr FooPtr;
         


        
16条回答
  •  隐瞒了意图╮
    2020-12-13 00:31

    How about:

    template 
    class Shared
    {
        public: 
            typedef std::shared_ptr Ptr; // or boost::shared_ptr if you will
    };
    

    Then allowing any Shared class to have their own Ptr object, as in:

    class myClass : public Shared
    {
    };
    
    int main()
    {
        myClass::Ptr object;
        //...
        object->foo();
    }
    

提交回复
热议问题