Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43f4bbd

Browse files
committed
#208-implement slices
Enhanced. Still to be tested.
1 parent83f468c commit43f4bbd

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

‎cpp-strings/cppstrings.h‎

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,20 +1860,12 @@ namespace pcs // i.e. "pythonic c++ strings"
18601860
//--- iterating -----------------------------------
18611861
inlineconst IntTbegin(const CppString& str)noexcept//!< starts iterating on specified CppString.
18621862
{
1863-
if (_start == DEFAULT)
1864-
_start =0;
1865-
elseif (_start <0)
1866-
_start += str.size();
1867-
1868-
if (_stop == DEFAULT)
1869-
_stop = str.size();
1870-
elseif (_stop <0)
1871-
_stop += str.size();
1872-
1873-
if (_step == DEFAULT)
1874-
_step =1;
1863+
return_prepare_iterating(IntT(str.size()));
1864+
}
18751865

1876-
return _index = _start;
1866+
inlineconst IntTbegin(const CppWString& wstr)noexcept//!< starts iterating on specified CppWString.
1867+
{
1868+
return_prepare_iterating(IntT(wstr.size()));
18771869
}
18781870

18791871
inlineconstboolend()constnoexcept//!< returns true when iterating is over, or false otherwise.
@@ -1899,6 +1891,24 @@ namespace pcs // i.e. "pythonic c++ strings"
18991891
IntT _step{1 };
19001892

19011893
IntT _index{0 };
1894+
1895+
const IntT_prepare_iterating(const IntT str_size)noexcept
1896+
{
1897+
if (_start == DEFAULT)
1898+
_start =0;
1899+
elseif (_start <0)
1900+
_start += str_size;
1901+
1902+
if (_stop == DEFAULT)
1903+
_stop = str_size;
1904+
elseif (_stop <0)
1905+
_stop += str_size;
1906+
1907+
if (_step == DEFAULT)
1908+
_step =1;
1909+
1910+
return _index = _start;
1911+
}
19021912
};
19031913

19041914

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp