Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base64 not work well on vc2019 #17

Open
a645162 opened this issue Apr 12, 2019 · 0 comments
Open

base64 not work well on vc2019 #17

a645162 opened this issue Apr 12, 2019 · 0 comments

Comments

@a645162
Copy link

a645162 commented Apr 12, 2019

Expression: cannot seek string iterator after end

The program is normal under the clang compiler, but on vc2019, Microsoft will report an error on the judgment condition of your "for" statement. If the judgment of the maximum pointer of the iterator exceeds the error, the debug channel will report an error, and the output of the Release channel will be abnormal.
Assuming the string length is "length", then it is normal when you execute begin+length<end, but after each round of the loop, the pointer is shifted back by 3 bits, then begin+length+1<end and begin+length+2<end two judgment statements will report an error.

I have a solution:
Change
for (auto it = begin; it < end; it += 3) {
to

auto length = end - begin;
for (auto i = 0; i < length; i += 3) {
				auto it = begin + i;

Change

if (it + 1 < end) {
if (it + 2 < end) {

to

if (i + 1 < length) {
if (i + 2 < length) {

Personally think this is the easiest solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant