From 840e63e6b25b6d057206d1f312056ff1e49b7686 Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 15 Sep 2021 09:28:54 +0100 Subject: [PATCH] Prefer tags for 'boost::intrusive::list' rather than list_member_hook<> list_member_hook<> is very troublesome in MSVC and is known to cause problems in other compilers when used inside a class which has a virtual base class. --- libs/temporal/temporal/tempo.h | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 9c4902743d..2b3b4db924 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -67,7 +67,8 @@ class TempoMap; * its superclock and beat time defined and no translation between them is possible. */ -class LIBTEMPORAL_API Point { +typedef boost::intrusive::list_base_hook> point_hook; +class LIBTEMPORAL_API Point : public point_hook { public: Point (TempoMap const & map, superclock_t sc, Beats const & b, BBT_Time const & bbt) : _sclock (sc), _quarters (b), _bbt (bbt), _map (&map) {} Point (TempoMap const & map, XMLNode const &); @@ -119,8 +120,6 @@ class LIBTEMPORAL_API Point { TempoMap const & map() const { return *_map; } - boost::intrusive::list_member_hook<> _point_hook; - protected: superclock_t _sclock; Beats _quarters; @@ -349,7 +348,8 @@ class LIBTEMPORAL_API Meter { /* A MeterPoint is literally just the combination of a Meter with a Point */ -class LIBTEMPORAL_API MeterPoint : public Meter, public virtual Point +typedef boost::intrusive::list_base_hook> meter_hook; +class LIBTEMPORAL_API MeterPoint : public Meter, public meter_hook, public virtual Point { public: MeterPoint (TempoMap const & map, Meter const & m, superclock_t sc, Beats const & b, BBT_Time const & bbt) : Point (map, sc, b, bbt), Meter (m) {} @@ -366,8 +366,6 @@ class LIBTEMPORAL_API MeterPoint : public Meter, public virtual Point return Meter::operator!= (other) || Point::operator!= (other); } - boost::intrusive::list_member_hook<> _meter_hook; - XMLNode& get_state () const; }; @@ -377,7 +375,8 @@ class LIBTEMPORAL_API MeterPoint : public Meter, public virtual Point * time-at-quarter-note on demand. */ -class LIBTEMPORAL_API TempoPoint : public Tempo, public virtual Point +typedef boost::intrusive::list_base_hook> tempo_hook; +class LIBTEMPORAL_API TempoPoint : public Tempo, public tempo_hook, public virtual Point { public: TempoPoint (TempoMap const & map, Tempo const & t, superclock_t sc, Beats const & b, BBT_Time const & bbt) : Point (map, sc, b, bbt), Tempo (t), _omega (0.0) {} @@ -424,8 +423,6 @@ class LIBTEMPORAL_API TempoPoint : public Tempo, public virtual Point return Tempo::operator!= (other) || Point::operator!= (other); } - boost::intrusive::list_member_hook<> _tempo_hook; - Beats quarters_at_sample (samplepos_t sc) const { return quarters_at_superclock (samples_to_superclock (sc, TEMPORAL_SAMPLE_RATE)); } Beats quarters_at_superclock (superclock_t sc) const; @@ -524,15 +521,14 @@ class LIBTEMPORAL_API TempoMetric { * position is given by a Point that might use superclock or Beats, and the * Point's BBT time member is overwritten. */ -class LIBTEMPORAL_API MusicTimePoint : public virtual TempoPoint, public virtual MeterPoint +typedef boost::intrusive::list_base_hook> bartime_hook; +class LIBTEMPORAL_API MusicTimePoint : public bartime_hook, public virtual TempoPoint, public virtual MeterPoint { public: MusicTimePoint (TempoMap const & map, superclock_t sc, Beats const & b, BBT_Time const & bbt, Tempo const & t, Meter const & m) : Point (map, sc, b, bbt), TempoPoint (t, *this), MeterPoint (m, *this) {} // MusicTimePoint (BBT_Time const & bbt_time, Point const & p) : Point (p), TempoPoint (p.map().tempo_at (p.sclock()), p), MeterPoint (p.map().meter_at (p.sclock()), p) { _bbt = bbt_time; } MusicTimePoint (TempoMap const & map, XMLNode const &); - boost::intrusive::list_member_hook<> _bartime_hook; - bool operator== (MusicTimePoint const & other) const { return TempoPoint::operator== (other) && MeterPoint::operator== (other); } @@ -818,15 +814,10 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible LIBTEMPORAL_API void add_state (XMLNode*) {} }; - typedef boost::intrusive::member_hook, &TempoPoint::_tempo_hook> TempoHookOption; - typedef boost::intrusive::member_hook, &MeterPoint::_meter_hook> MeterHookOption; - typedef boost::intrusive::member_hook, &MusicTimePoint::_bartime_hook> BarTimeHookOption; - typedef boost::intrusive::member_hook, &Point::_point_hook> PointHookOption; - - typedef boost::intrusive::list Tempos; - typedef boost::intrusive::list Meters; - typedef boost::intrusive::list MusicTimes; - typedef boost::intrusive::list Points; + typedef boost::intrusive::list> Tempos; + typedef boost::intrusive::list> Meters; + typedef boost::intrusive::list> MusicTimes; + typedef boost::intrusive::list> Points; LIBTEMPORAL_API Beats quarters_at_sample (samplepos_t sc) const { return quarters_at_superclock (samples_to_superclock (sc, TEMPORAL_SAMPLE_RATE)); } LIBTEMPORAL_API Beats quarters_at_superclock (superclock_t sc) const;