Skip to content

Commit b428966

Browse files
committed
#20 - Implement method CppStringT::index_n()
Completed.
1 parent fc98a07 commit b428966

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cpp-strings/cppstrings.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ class CppStringT : public std::basic_string<CharT>
226226
}
227227

228228

229+
//--- index_n() ---------------------------------------
230+
/** Like find_n(sub, start, length), but raises NotFoundException when the substring is not found. */
231+
inline constexpr size_type index_n(const CppStringT& sub, const size_type start, const size_type length) const
232+
{
233+
return index_n(sub, start, start + length - 1);
234+
}
235+
236+
/** Like find_n(sub, length), but raises NotFoundException when the substring is not found. */
237+
inline constexpr size_type index_n(const CppStringT& sub, const size_type length) const
238+
{
239+
return index_n(sub, 0, length - 1);
240+
}
241+
242+
243+
229244
//--- is_punctuation() --------------------------------
230245
/** \brief Returns true if the string contains only one character and if this character belongs to the ASCII punctuation set. */
231246
inline const bool is_punctuation() const noexcept

0 commit comments

Comments
 (0)