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

修复bug:在MSVC debug环境下,直接value解引用会触发cannot access empty value optional断… #185

Merged
Merged
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions ormpp/mysql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class mysql {
std::map<size_t, std::vector<char>> &mp, B &is_null) {
using U = std::remove_const_t<std::remove_reference_t<T>>;
if constexpr (is_optional_v<U>::value) {
using value_type = typename U::value_type;
value = value_type();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改好点:

if(!value.has_value()) {
  value = value_type{};
}

只在没有初始化的时候才给默认值。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按照修改意见修改

return set_param_bind(param_bind, *value, i, mp, is_null);
}
else if constexpr (std::is_enum_v<U>) {
Expand Down
Loading