@@ -487,33 +487,6 @@ namespace pcs // i.e. "pythonic c++ strings"
487487#endif
488488 }
489489
490- /* * \brief Returns true if this string contains the passed C-string, or false otherwise.*/
491- inline constexpr bool contains (const CharT* substr)const noexcept
492- {
493- if (substr ==nullptr )
494- // just to avoid system error on invalid access
495- return true ;
496-
497- #if (defined(_HAS_CXX23) && _HAS_CXX23) || (!defined(_HAS_CXX23) && __cplusplus >= 202302L)
498- // c++23 and above already defines this method
499- return MyBaseClass::contains (substr);
500- #else
501- return contains (CppStringT (substr));
502- #endif
503- }
504-
505- /* * \brief Returns true if this string contains the passed char, or false otherwise.*/
506- inline constexpr bool contains (const CharT& ch)const noexcept
507- {
508- #if (defined(_HAS_CXX23) && _HAS_CXX23) || (!defined(_HAS_CXX23) && __cplusplus >= 202302L)
509- // c++23 and above already defines this method
510- return MyBaseClass::contains (ch);
511- #else
512- // up to c++20, we have to implement this method
513- return std::ranges::any_of (*this , [ch](const value_type c) ->bool {return c == ch; });
514- #endif
515- }
516-
517490
518491// --- contains_n() ------------------------------------
519492/* * Returns true if the passed string is found within the slice str[start:start+count-1], or false otherwise.
@@ -530,32 +503,6 @@ namespace pcs // i.e. "pythonic c++ strings"
530503 }
531504 }
532505
533- /* * Returns true if the passed C-string is found within the slice str[start:start+count-1], or false otherwise.*/
534- inline constexpr bool contains_n (const CharT* sub,const size_type start,const size_type count = -1 )const noexcept
535- {
536- if (sub ==nullptr )
537- // just to avoid system error on invalid access
538- return true ;
539-
540- try {
541- return this ->substr (start, count).contains (sub);
542- }
543- catch (...) {
544- return false ;
545- }
546- }
547-
548- /* * Returns true if the passed char is found within the slice str[start:start+count-1], or false otherwise.*/
549- inline constexpr bool contains_n (const CharT ch,const size_type start,const size_type count = -1 )const noexcept
550- {
551- try {
552- return this ->substr (start, count).contains (ch);
553- }
554- catch (...) {
555- return false ;
556- }
557- }
558-
559506
560507// --- count() -----------------------------------------
561508/* * \brief Returns the number of non-overlapping occurrences of substring sub in the range [start, end].*/
@@ -698,42 +645,6 @@ namespace pcs // i.e. "pythonic c++ strings"
698645return find_n (sub, start, end_ - start +1 );
699646 }
700647
701- /* * Returns the lowest index in the string where character ch is found within the slice str[start:end], or -1 (i.e. 'npos') if ch is not found.
702- *
703- * Note: this method should be used only if you need to know the position of
704- * sub. To check if sub is a substring or not, use the method contains().
705- *
706- * CAUTION: empty substrings are considered to be in the string if start and
707- * end positions are both less than the string size and if start <= end.
708- *
709- * \see find_n(), rfind() and rfind_n().
710- * \see index(), index_n(), rindex() and rindex_n().
711- */
712- inline constexpr size_typefind (const CharT ch,const size_type start =0 ,const size_type end = -1 )const noexcept
713- {
714- return find (CppStringT (ch), start, end);
715- }
716-
717- /* * Returns the lowest index in the string where null-terminated string sub is found within the slice str[start:end], or -1 (i.e. 'npos') if sub is not found.
718- *
719- * Note: this method should be used only if you need to know the position of
720- * sub. To check if sub is a substring or not, use the method contains().
721- *
722- * CAUTION: empty substrings are considered to be in the string if start and
723- * end positions are both less than the string size and if start <= end. The
724- * returned position is 0.
725- *
726- * \see find_n(), rfind() and rfind_n().
727- * \see index(), index_n(), rindex() and rindex_n().
728- */
729- inline constexpr size_typefind (const CharT* sub,const size_type start =0 ,const size_type end = -1 )const noexcept
730- {
731- if (sub ==nullptr )
732- return CppStringT::npos;
733- else
734- return find (CppStringT (sub), start, end);
735- }
736-
737648
738649// --- find_n() ----------------------------------------
739650/* * Returns the lowest index in the string where substring sub is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if sub is not found.
@@ -780,64 +691,6 @@ namespace pcs // i.e. "pythonic c++ strings"
780691return find_n (sub,0 , count);
781692 }
782693
783- /* * Returns the lowest index in the string where character ch is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if ch is not found.
784- *
785- * Note: this method should be used only if you need to know the position of
786- * sub. To check if sub is a substring or not, use the method contains_n().
787- *
788- * CAUTION: empty substrings are considered to be in the string if start and
789- * end positions are both less than the string size and if start <= end.
790- *
791- * \see find(), rfind() and rfind_n().
792- * \see index(), index_n(), rindex() and rindex_n().
793- */
794- inline constexpr size_typefind_n (const CharT ch,const size_type start,const size_type count)const noexcept
795- {
796- return find_n (CppStringT (ch), start, count);
797- }
798-
799- /* * Returns the lowest index in the string where character ch is found within the slice str[0:count-1], or -1 (i.e. 'npos') if ch is not found.
800- *
801- * Note: this method should be used only if you need to know the position of
802- * sub. To check if sub is a substring or not, use the method contains_n().
803- *
804- * \see find(), rfind() and rfind_n().
805- * \see index(), index_n(), rindex() and rindex_n().
806- */
807- inline constexpr size_typefind_n (const CharT ch,const size_type count)const noexcept
808- {
809- return find_n (CppStringT (ch),0 , count);
810- }
811-
812- /* * Returns the lowest index in the string where null-terminated substring sub is found within the slice str[start:start+count-1], or -1 (i.e. 'npos') if sub is not found.
813- *
814- * Note: this method should be used only if you need to know the position of
815- * sub. To check if sub is a substring or not, use the method contains_n().
816- *
817- * \see find(), rfind() and rfind_n().
818- * \see index(), index_n(), rindex() and rindex_n().
819- */
820- inline constexpr size_typefind_n (const CharT* sub,const size_type start,const size_type count)const noexcept
821- {
822- if (sub ==nullptr )
823- return CppStringT::npos;
824- else
825- return find_n (CppStringT (sub), start, count);
826- }
827-
828- /* * Returns the lowest index in the string where null-terminated substring sub is found within the slice str[0:count-1], or -1 (i.e. 'npos') if sub is not found.
829- *
830- * Note: this method should be used only if you need to know the position of
831- * sub. To check if sub is a substring or not, use the method contains_n().
832- *
833- * \see find(), rfind() and rfind_n().
834- * \see index(), index_n(), rindex() and rindex_n().
835- */
836- inline constexpr size_typefind_n (const CharT* sub,const size_type count)const noexcept
837- {
838- return find_n (sub,0 , count);
839- }
840-
841694
842695// --- index() -----------------------------------------
843696/* * Like find(const CppStringT&), but raises NotFoundException when the substring sub is not found.
@@ -855,36 +708,6 @@ namespace pcs // i.e. "pythonic c++ strings"
855708return ret_value;
856709 }
857710
858- /* * Like find(const CharT), but raises NotFoundException when character ch is not found.
859- *
860- * \see index_n(), rindex() and rindex_n().
861- * \see find(), find_n(), rfind() and rfind_n().
862- */
863- inline constexpr size_typeindex (const CharT ch,const size_type start =0 ,const size_type end = -1 )const
864- {
865- const size_type ret_value =find (ch, start, end);
866- if (ret_value == CppStringT::npos)
867- throw NotFoundException (" char not found in string." );
868- // throw NotFoundException(CppStringT(std::format("character \"{}\" not found in string \"{}\"", CppStringT(ch).c_str(), this->c_str()).c_str()));
869- else
870- return ret_value;
871- }
872-
873- /* * Like find(const CharT*), but raises NotFoundException when the substring sub is not found.
874- *
875- * \see index_n(), rindex() and rindex_n().
876- * \see find(), find_n(), rfind() and rfind_n().
877- */
878- inline constexpr size_typeindex (const CharT* sub,const size_type start =0 ,const size_type end = -1 )const
879- {
880- const size_type ret_value =find (sub, start, end);
881- if (ret_value == CppStringT::npos)
882- throw NotFoundException (" substring not found in string" );
883- // throw NotFoundException(CppStringT(std::format("substring \"{}\" not found in string \"{}\"", CppStringT(sub).c_str(), this->c_str()).c_str()));
884- else
885- return ret_value;
886- }
887-
888711
889712// --- index_n() ---------------------------------------
890713/* * Like find_n(sub, start, count), but raises NotFoundException when the substring is not found.
@@ -907,46 +730,6 @@ namespace pcs // i.e. "pythonic c++ strings"
907730return index (sub,0 , count);
908731 }
909732
910- /* * Like find_n(sub, start, count), but raises NotFoundException when the character is not found.
911- *
912- * \see index_n(), rindex() and rindex_n().
913- * \see find(), find_n(), rfind() and rfind_n().
914- */
915- inline constexpr size_typeindex_n (const CharT ch,const size_type start,const size_type count)const
916- {
917- return index (ch, start, start + count -1 );
918- }
919-
920- /* * Like find_n(sub, count), but raises NotFoundException when the character is not found.
921- *
922- * \see index_n(), rindex() and rindex_n().
923- * \see find(), find_n(), rfind() and rfind_n().
924- */
925- inline constexpr size_typeindex_n (const CharT ch,const size_type count)const
926- {
927- return index (ch,0 , count);
928- }
929-
930- /* * Like find_n(sub, start, count), but raises NotFoundException when the null-terminated substring is not found.
931- *
932- * \see index_n(), rindex() and rindex_n().
933- * \see find(), find_n(), rfind() and rfind_n().
934- */
935- inline constexpr size_typeindex_n (const CharT* sub,const size_type start,const size_type count)const
936- {
937- return index (sub, start, start + count -1 );
938- }
939-
940- /* * Like find_n(sub, count), but raises NotFoundException when the null-terminated substring is not found.
941- *
942- * \see index_n(), rindex() and rindex_n().
943- * \see find(), find_n(), rfind() and rfind_n().
944- */
945- inline constexpr size_typeindex_n (const CharT* sub,const size_type count)const
946- {
947- return index (sub,0 , count);
948- }
949-
950733
951734// --- isalnum() ---------------------------------------
952735/* * \brief Returns true if all characters in the string are alphanumeric and there is at least one character, or false otherwise.*/
@@ -1378,7 +1161,8 @@ namespace pcs // i.e. "pythonic c++ strings"
13781161return rfind (sub, start,this ->size () -1 );
13791162 }
13801163
1381- /* * Returns the highest index in the string where substring sub is found in the whole string, or -1 (i.e. 'npos') if sub is not found.
1164+
1165+ /* * Returns the highest index in the string where C-substring sub is found in the whole string, or -1 (i.e. 'npos') if sub is not found.
13821166 *
13831167 * Note that this is an offset from the start of the string, not the end.
13841168 *