@@ -243,13 +243,16 @@ namespace pcs // i.e. "pythonic c++ strings"
243243 {
244244 if (start > end)
245245 return false ;
246-
246+ else
247+ return std::any_of (suffixes.cbegin (), suffixes.cend (), this ->substr (start, end).ends_with );
248+ /*
247249 for (auto& suffix : suffixes) {
248250 if (this->substr(start, end).ends_with(suffix))
249251 return true;
250252 }
251253
252254 return false;
255+ */
253256 }
254257
255258
@@ -1197,7 +1200,7 @@ namespace pcs // i.e. "pythonic c++ strings"
11971200 case value_type (' \x1e ' ): // Record Separator
11981201 case value_type (' \x85 ' ): // Next Line (C1 Control Code)
11991202#pragma warning(push)
1200- #pragma warning(disable: 4566)
1203+ #pragma warning(disable: 4566) // to get no warning when current page code is not compatible with next unicode points
12011204 case value_type (' \u2028 ' ): // Line Separator
12021205 case value_type (' \u2029 ' ): // Paragraph Separator
12031206#pragma warning(pop)
@@ -1245,18 +1248,48 @@ namespace pcs // i.e. "pythonic c++ strings"
12451248 }
12461249
12471250
1248- // --- title () ----- ------------------------------------
1249- /* * \brief Returns a titlecased copy of the string where words start with an uppercase character and the remaining characters are lowercase . */
1250- inline CppStringT title ( ) const noexcept
1251+ // --- startswith () ------------------------------------
1252+ /* * Returns true if the string starts with the specified suffix, otherwise returns false. Test begins at start position and stops at end position . */
1253+ inline const bool startswith ( const CppStringT& suffix, const size_type start, const size_type end ) const noexcept
12511254 {
1252- return * this ;
1255+ return startswith (std::span{ suffix }, start, end) ;
12531256 }
12541257
1258+ /* * Returns true if the string starts with the specified suffix, otherwise returns false. Test begins at start position and stops at end of string. */
1259+ inline const bool startswith (const CppStringT& suffix, const size_type start) const noexcept
1260+ {
1261+ return startswith (std::span{ suffix }, start, this ->size () - 1 );
1262+ }
1263+
1264+ /* * Returns true if the string starts with the specified suffix, otherwise returns false. Test runs on the whole string. */
1265+ inline const bool startswith (const CppStringT& suffix) const noexcept
1266+ {
1267+ return this ->starts_with (suffix);
1268+ }
12551269
1256- // --- startswith --------------------------------------
1257- inline const bool startswith (const CppStringT& prefix ) const noexcept
1270+ /* * Returns true if the string starts with any of the specified suffixes, otherwise returns false. Test begins at start position and stops at end of string. */
1271+ inline const bool startswith (const std::span< CppStringT>& suffixes, const size_type start, const size_type end ) const noexcept
12581272 {
1273+ if (start > end)
1274+ return false ;
1275+ else
1276+ return std::any_of (suffixes.cbegin (), suffixes.cend (), this ->substr (start, end).starts_with );
1277+ /*
1278+ for (auto& suffix : suffixes) {
1279+ if (this->substr(start, end).starts_with(suffix))
1280+ return true;
1281+ }
1282+
12591283 return false;
1284+ */
1285+ }
1286+
1287+
1288+ // --- title() -----------------------------------------
1289+ /* * \brief Returns a titlecased copy of the string where words start with an uppercase character and the remaining characters are lowercase. */
1290+ inline CppStringT title () const noexcept
1291+ {
1292+ return *this ;
12601293 }
12611294
12621295
0 commit comments