@@ -144,20 +144,30 @@ inline StringConverter GetAnyFromStringFunctor<void>()
144144
145145// ------------------------------------------------------------------
146146
147- template <typename T> [[nodiscard]]
148- std::string toStr (T value)
147+ template <typename T> [[nodiscard]]
148+ std::string toStr (const T& value)
149149{
150+ static_assert (std::is_arithmetic_v<T>,
151+ " You need a template specialization of BT::toStr() and "
152+ " it must be consistent with the implementation of BT::convertFromString" );
150153 return std::to_string (value);
151154}
152155
153- std::string toStr (const std::string& value);
156+ template <> [[nodiscard]] inline
157+ std::string toStr<bool >(const bool & value) {
158+ return value ? " true" : " false" ;
159+ }
154160
155- template <>
156- std::string toStr<BT::NodeStatus>(BT::NodeStatus status);
161+ template <> [[nodiscard]]
162+ std::string toStr<std::string>(const std::string& value);
163+
164+ template <> [[nodiscard]]
165+ std::string toStr<BT::NodeStatus>(const BT::NodeStatus& status);
157166
158167/* *
159168 * @brief toStr converts NodeStatus to string. Optionally colored.
160169 */
170+ [[nodiscard]]
161171std::string toStr (BT::NodeStatus status, bool colored);
162172
163173std::ostream& operator <<(std::ostream& os, const BT::NodeStatus& status);
@@ -166,12 +176,12 @@ std::ostream& operator<<(std::ostream& os, const BT::NodeStatus& status);
166176 * @brief toStr converts NodeType to string.
167177 */
168178template <> [[nodiscard]]
169- std::string toStr<BT::NodeType>(BT::NodeType type);
179+ std::string toStr<BT::NodeType>(const BT::NodeType& type);
170180
171181std::ostream& operator <<(std::ostream& os, const BT::NodeType& type);
172182
173183template <> [[nodiscard]]
174- std::string toStr<BT::PortDirection>(BT::PortDirection direction);
184+ std::string toStr<BT::PortDirection>(const BT::PortDirection& direction);
175185
176186std::ostream& operator <<(std::ostream& os, const BT::PortDirection& type);
177187
@@ -203,6 +213,7 @@ using enable_if_not = typename std::enable_if<!Predicate::value>::type*;
203213 * */
204214template <typename T>
205215using Expected = nonstd::expected<T, std::string>;
216+
206217#ifdef USE_BTCPP3_OLD_NAMES
207218// note: we also use the name Optional instead of expected because it is more intuitive
208219// for users that are not up to date with "modern" C++
0 commit comments