vendredi 2 mars 2018

using parameter's private data in constructor

here is the codes:

template<typename _Tp, _Lock_policy _Lp>
  class __shared_ptr
  {
public:
template<typename _Tp1, typename = _Convertible<_Tp1*>>
      __shared_ptr(const __shared_ptr<_Tp1, _Lp>& __r) noexcept
      : _M_ptr(__r._M_ptr), _M_refcount(__r._M_refcount)
      { }
  ...
private:
  ...
  __shared_count<_Lp>  _M_refcount;
  };

Question:

_M_refcount is a private data, why it can be used in _M_refcount(__r._M_refcount) and do not have a error?

Aucun commentaire:

Enregistrer un commentaire