lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Almost, but not quite: C++ STL in LilyPond


From: Dan Eble
Subject: Re: Almost, but not quite: C++ STL in LilyPond
Date: Tue, 5 May 2020 17:32:22 -0400

On May 5, 2020, at 13:37, David Kastrup <address@hidden> wrote:
> 
> What I have ready-to-use is something that stores like an SCM value but
> behaves like a Smob pointer with regard to -> and * usage.

Oh.  I believe I have some of that too.  Excerpt:

// specialization for pointers
template <class T>
class ly_scm_t<T *>
{
private:
  using traits = ly_scm_traits<T *>;

private:
  SCM scm_ = SCM_UNDEFINED;

public:
  ly_scm_t () = default;
  ly_scm_t (const ly_scm_t &) = default;
  ly_scm_t &operator = (const ly_scm_t &) = default;
  ~ly_scm_t () = default;

  explicit ly_scm_t (T *v) : scm_ (traits::to_scm (v)) {}

  explicit operator bool () const { return traits::has_value (scm_); }
  operator T *() const { return traits::to_value (scm_); }
  T *operator ->() { return operator T * (); }
  // TODO: operator *
};
— 
Dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]