mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Fix ctl::string_view const iteration issue
This commit is contained in:
parent
baad1df71d
commit
a120bc7149
2 changed files with 12 additions and 2 deletions
|
@ -109,12 +109,12 @@ struct string_view
|
||||||
return p[n - 1];
|
return p[n - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const_iterator begin() noexcept
|
constexpr const_iterator begin() const noexcept
|
||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const_iterator end() noexcept
|
constexpr const_iterator end() const noexcept
|
||||||
{
|
{
|
||||||
return p + n;
|
return p + n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
// PERFORMANCE OF THIS SOFTWARE.
|
// PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
#include "ctl/string.h"
|
||||||
#include "ctl/string_view.h"
|
#include "ctl/string_view.h"
|
||||||
#include "libc/mem/leaks.h"
|
#include "libc/mem/leaks.h"
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
|
@ -172,5 +173,14 @@ main(int argc, char* argv[])
|
||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ctl::string b;
|
||||||
|
const ctl::string_view s = "hi";
|
||||||
|
for (char c : s)
|
||||||
|
b += c;
|
||||||
|
if (b != "hi")
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
CheckForMemoryLeaks();
|
CheckForMemoryLeaks();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue