# HG changeset patch # User John W. Eaton # Date 1711645225 14400 # Node ID 2e840d58dba7243cc889fc263e6660c85fcdaaba # Parent 1077e4739169ca7356293fe03e53b6f96b1b2b53 comment_list: don't inherit from std::list * comment-list.h (class comment_list): Store std::list as data member instead of using inheritance. Adjust member functions. (comment_list::reference, comment_list::const_reference, comment_list::iterator, comment_list::const_iterator): New typedefs. (comment_list::clear, comment_list::front, comment_list::back, comment_list::begin, comment_list::end, comment_list::empty): New methods. diff -r 1077e4739169 -r 2e840d58dba7 libinterp/parse-tree/comment-list.h --- a/libinterp/parse-tree/comment-list.h Tue Apr 02 12:53:50 2024 -0400 +++ b/libinterp/parse-tree/comment-list.h Thu Mar 28 13:00:25 2024 -0400 @@ -29,6 +29,7 @@ #include "octave-config.h" #include +#include #include OCTAVE_BEGIN_NAMESPACE(octave) @@ -105,31 +106,53 @@ bool m_uses_hash_char; }; -class comment_list : public std::list +class comment_list { public: OCTAVE_DEFAULT_CONSTRUCT_COPY_MOVE_DELETE (comment_list) + typedef std::list::reference reference; + typedef std::list::const_reference const_reference; + + typedef std::list::iterator iterator; + typedef std::list::const_iterator const_iterator; + void append (const comment_elt& elt) { - push_back (elt); + m_list.push_back (elt); } void append (const std::string& s, comment_elt::comment_type t = comment_elt::unknown, bool uses_hash_char = false) { - push_back (comment_elt (s, t, uses_hash_char)); + m_list.push_back (comment_elt (s, t, uses_hash_char)); } + void clear () { m_list.clear (); } + + bool empty () const { return m_list.empty (); } + + reference front () { return m_list.front (); } + reference back () { return m_list.back (); } + + const_reference front () const { return m_list.front (); } + const_reference back () const { return m_list.back (); } + + iterator begin () { return m_list.begin (); } + iterator end () { return m_list.end (); } + + const_iterator begin () const { return m_list.begin (); } + const_iterator end () const { return m_list.end (); } + comment_list * dup () const; // Documentation for functions is typically the first block of // comments that doesn't look like a copyright statement. comment_elt find_doc_comment () const { - for (const auto& elt : *this) + for (const auto& elt : m_list) { // FIXME: should we also omit end-of-line comments? if (! elt.is_copyright ()) @@ -143,6 +166,10 @@ { return find_doc_comment().text (); } + +private: + + std::list m_list; }; OCTAVE_END_NAMESPACE(octave)