File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -119,8 +119,8 @@ class CppStringT : public std::basic_string<CharT>
119119
120120
121121 // --- center() ----------------------------------------
122- /* * Returns the string centered in a string of length width.
123- * *
122+ /* * \brief Returns the string centered in a string of length width.
123+ *
124124 * Padding is done using the specified fillchar (default is an ASCII space).
125125 * A copy of the original string is returned if width is less than or equal
126126 * to the length of the string. The original string remains unchanged.
@@ -135,6 +135,22 @@ class CppStringT : public std::basic_string<CharT>
135135 }
136136
137137
138+ // --- find() ------------------------------------------
139+ /* * Returns the lowest index in the string where substring sub is found within the slice string[start:end], or -1 if sub is not found.
140+ *
141+ * Note: this method should be used only if you need to know the position
142+ * of sub. To check if sub is a substring or not, use the method contains().
143+ */
144+ inline constexpr size_type find (const CppStringT& sub, const size_type start, const size_type end) const noexcept
145+ {
146+ const size_type l = this ->length ();
147+ if (start >= l || end >= l || start > end)
148+ return -1 ;
149+ else
150+ return MyBaseClass (this ->cbegin () + start, this ->cbegin () + end ()).find (sub);
151+ }
152+
153+
138154 // --- is_punctuation() --------------------------------
139155 /* * \brief Returns true if the string contains only one character and if this character belongs to the ASCII punctuation set. */
140156 inline const bool is_punctuation () const noexcept
You can’t perform that action at this time.
0 commit comments