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

char reading in io_fields.hpp does not ignore newline and spaces #159

Open
PedroAreiasIST opened this issue Jan 30, 2024 · 0 comments
Open

Comments

@PedroAreiasIST
Copy link

Since the opening curly braces '{' is read as a char, newlines and spaces set the state "failbit".

This can be an issue for serializing containers in a struct, which usually require the size to be read and then the sequence.

It would be silly to pollute users serialization functions for containers with the curly braces.

Therefore, I changed my local copy of io_fields to read:
char parenthis = {}; // That is in the original.
do
{
in >> parenthis;
}
while(parenthis=='\n'||parenthis==' ');
if (parenthis != '{') in.setstate(std::basic_istream<Char, Traits>::failbit);

Will think about a better solution later.

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