smart-pointers

Which non-shared Smart Pointer for class member variables

When I have a class that contains pointers as member variables what type of smart pointer should they have if I want don't want to use plain pointers? They do not need to be shared (so no shared_ptr necessary). scoped_ptr won't work since I often need to build the objects outside of the initialization list. Or is it maybe common practic...

C++0x Smart Pointer Comparisons: Inconsistent, what's the rationale?

In C++0x (n3126), smart pointers can be compared, both relationally and for equality. However, the way this is done seems inconsistent to me. For example, shared_ptr defines operator< be equivalent to: template <typename T, typename U> bool operator<(const shared_ptr<T>& a, const shared_ptr<T>& b) { return std::less<void*>()(a.get(...

C++ smart pointer to statically and dynamically allocated resource

Hello, my base class need to expose a method that for some derived classes would return a smart pointer to dynamically allocated array, and for some other derived classes would return a pointer/reference to statically allocated one. example: class Base { public: virtual ??? foo()=0; } class A : public Base { private: float ar...