Skip to content

Strategy for dealing with members of templates with lifetimes #49

Open
@seanbaxter

Description

@seanbaxter

Had a problem with this example. The rc_inner struct has data members with lifetimes (manually_drop data_). That lifetime refers not to the rc_inner but to the outer class rc. This needs some special normalization.

What's the strategy? Simplest is to just error. But it seems we can implicitly provide lifetime parameters on rc_inner. Which ones? Only the ones used? All the ones in the surrounding class? When does naming rc_inner give it implicit lifetime arguments?

template<class T+>
class [[unsafe::send(false)]] rc
{
  struct rc_inner;
  rc_inner* unsafe p_;

  struct rc_inner
  {
    manually_drop<T> data_;
    std::size_t strong_;
    std::size_t weak_;

    explicit
    rc_inner(T data) noexcept safe;
  };

public:

  explicit rc(T t) safe;
  rc(rc const^ rhs) safe;
  [[unsafe::drop_only(T)]] ~rc() safe;

  T const^ operator*(self const^) noexcept safe {
    return *self->p_->data_.get();
  }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions