boostorg / pfr

std::tuple like methods for user defined types without any macro or boilerplate code
https://boost.org/libs/pfr
Boost Software License 1.0
1.34k stars 161 forks source link

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

Open PedroAreiasIST opened 9 months ago

PedroAreiasIST commented 9 months ago

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.