File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2323// =============================================================
2424#include < algorithm>
2525#include < cctype>
26+ #include < format>
2627#include < stdexcept>
2728#include < string>
2829#include < vector>
29- // #include <initializer_list>
3030
3131
3232// =============================================================
@@ -214,6 +214,18 @@ class CppStringT : public std::basic_string<CharT>
214214 }
215215
216216
217+ // --- index() -----------------------------------------
218+ /* * Like find(), but raises NotFoundException when the substring is not found. */
219+ inline constexpr size_type index (const CppStringT& sub, const size_type start, const size_type end) const
220+ {
221+ const size_type ret_value = find (sub, start, end);
222+ if (size_type == CppStringT::npos)
223+ throw NotFoundException (std::format (" substring \" {}\" not found in string \" {}\" " , sub, this ->c_str ()));
224+ else
225+ return ret_value;
226+ }
227+
228+
217229 // --- is_punctuation() --------------------------------
218230 /* * \brief Returns true if the string contains only one character and if this character belongs to the ASCII punctuation set. */
219231 inline const bool is_punctuation () const noexcept
You can’t perform that action at this time.
0 commit comments