@@ -80,11 +80,11 @@ class Child {
8080
8181 /* * @brief Check to see if the Child has a parent. */
8282 const bool has_parent () noexcept { return parent != nullptr ; }
83- const bool has_parent () const noexcept { return parent != nullptr ; }
83+ [[nodiscard]] const bool has_parent () const noexcept { return parent != nullptr ; }
8484
8585 // TODO: Look in to making these references instead of pointer returns
8686 /* * @brief Get the Child's parent. */
87- Child *get_parent () const noexcept { return parent; }
87+ [[nodiscard]] Child *get_parent () const noexcept { return parent; }
8888
8989 template <class C >
9090 C get_parent_as () const noexcept {
@@ -103,23 +103,23 @@ class Child {
103103
104104 /* --------- Formatter helper functions -----------*/
105105 // Check to see if the tree has a printer
106- const bool has_formatter () const noexcept ;
106+ [[nodiscard]] bool has_formatter () const noexcept ;
107107
108108 // Get the printer from the tree
109- Formatters::BaseFormatter &get_formatter () const noexcept ;
109+ [[nodiscard]] Formatters::BaseFormatter &get_formatter () const noexcept ;
110110
111- void set_formatter (const Formatters::BaseFormatter &formatter) {
112- this ->formatter = &const_cast <Formatters::BaseFormatter &>( formatter) ;
111+ void set_formatter (Formatters::BaseFormatter &formatter) {
112+ this ->formatter = &formatter;
113113 }
114114
115115 /* --------- Primary member functions -------------*/
116116
117117 /* * @brief Get the status of the object (success/failure) */
118- const bool get_status () const noexcept { return this ->status ; }
118+ [[nodiscard]] bool get_status () const noexcept { return this ->status ; }
119119 void failed () noexcept ; // Report failure to the object.
120120
121121 // Calculate the padding for printing this object
122- std::string padding () const noexcept ;
122+ [[nodiscard]] std::string padding () const noexcept ;
123123};
124124
125125/* >>>>>>>>>>>>>>>>>>>> Child <<<<<<<<<<<<<<<<<<<<<<<<<*/
@@ -133,7 +133,8 @@ class Child {
133133inline void Child::failed () noexcept {
134134 this ->status = false ;
135135 // propogates the failure up the tree
136- if (this ->has_parent ()) this ->get_parent ()->failed ();
136+ if (this ->has_parent ()) { this ->get_parent ()->failed ();
137+ }
137138}
138139
139140/* *
@@ -144,15 +145,19 @@ inline std::string Child::padding() const noexcept {
144145 return this ->has_parent () ? this ->get_parent ()->padding () + " " : " " ;
145146}
146147
147- inline const bool Child::has_formatter () const noexcept {
148- if (this ->formatter != nullptr ) return true ;
149- if (!this ->has_parent ()) return false ; // base case;
148+ inline bool Child::has_formatter () const noexcept {
149+ if (this ->formatter != nullptr ) { return true ;
150+ }
151+ if (!this ->has_parent ()) { return false ; // base case;
152+ }
150153 return parent->has_formatter ();
151154}
152155
153156inline Formatters::BaseFormatter &Child::get_formatter () const noexcept {
154- if (this ->formatter ) return *formatter;
155- if (!this ->has_parent ()) std::terminate ();
157+ if (this ->formatter != nullptr ) { return *formatter;
158+ }
159+ if (!this ->has_parent ()) { std::terminate ();
160+ }
156161 return parent->get_formatter ();
157162}
158163
0 commit comments