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
질문으로 우리가 1 호선 정의 할 때> 유형 유형 typename T
교체에 사용? 우리가 boost::shared_ptr
을 초기화 할 때 class Y
유형이 std::string
으로 바뀌 었습니다. 이제 문제는 우리가 왜 T
유형을 제공 할 필요가 없습니까? 우리가 그것을 암묵적으로한다면, 어디에서? 하는 템플릿 매개 변수가 부스트에 사용되는 :: shared_ptr의 생성자 원시 포인터