namespace boost {
template<typename T> class shared_ptr { // I have problems to understand the T
public:
template <class Y> explicit shared_ptr(Y* p);
template <class Y,class D> shared_ptr(Y* p,D d);
~shared_ptr();
shared_ptr(const shared_ptr & r);
template <class Y> explicit
shared_ptr(const weak_ptr<Y>& r);
template <class Y> explicit shared_ptr(std::auto_ptr<Y>& r);
shared_ptr& operator=(const shared_ptr& r);
void reset();
T& operator*() const;
T* operator->() const;
T* get() const;
bool unique() const;
long use_count() const;
operator unspecified-bool-type() const;
void swap(shared_ptr<T>& b);
};
template <class T,class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r);
}
Example of the usage of boost::shared_ptr:
boost::shared_ptr<std::string> ptr(new std::string("hello world")); // Line 1
質問>我々はタイプtypename T
を交換するために使用されるタイプライン1を定義するとき?私が理解しているのは、タイプclass Y
は、boost::shared_ptr
を初期化すると、std::string
に置き換えられます。さて、問題はなぜ我々はタイプT
を提供する必要がないということですか?私たちが暗黙のうちにそれをしたら、どこ?::生のポインタとのshared_ptrのコンストラクタ
は