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

fix(string): fix deserialization of string with default value #37

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions include/alpaca/detail/types/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ typename std::enable_if<!std::is_same_v<Container, std::ifstream>, bool>::type
from_bytes(std::basic_string<CharType> &value, Container &bytes,
std::size_t &current_index, std::size_t &end_index,
std::error_code &error_code) {

// clear out the value - this ensures that value will be only what is read
// from the stream, and not any previous data that may have been set during
// the construction of the containing object T().
value.clear();
if (current_index >= end_index) {
// end of input
// return true for forward compatibility
Expand Down Expand Up @@ -75,7 +78,10 @@ typename std::enable_if<std::is_same_v<Container, std::ifstream>, bool>::type
from_bytes(std::basic_string<CharType> &value, Container &bytes,
std::size_t &current_index, std::size_t &end_index,
std::error_code &error_code) {

// clear out the value - this ensures that value will be only what is read
// from the stream, and not any previous data that may have been set during
// the construction of the containing object T().
value.clear();
if (current_index >= end_index) {
// end of input
// return true for forward compatibility
Expand Down Expand Up @@ -109,4 +115,4 @@ from_bytes(std::basic_string<CharType> &value, Container &bytes,
} // namespace detail

} // namespace alpaca
#endif
#endif
Loading