Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
steve02081504 committed Oct 26, 2023
1 parent 243dbcb commit f1efb13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ namespace to_string_n{
constexpr struct to_string_t{
template<arithmetic_type T,numerical_representation Repres>
[[nodiscard]]string operator()(T&&val,const Repres&repres)const noexcept{
ELC_TEST_EVENTNAME("to_string");
const string_convert_impl<Repres> impl{repres};
return impl.to_string(forward<T>(val));
}
Expand All @@ -737,6 +738,7 @@ namespace to_string_n{
**/
template<fraction_float_type T,numerical_representation Repres>
[[nodiscard]]string fractional(T&&val,const Repres&repres)const noexcept{
ELC_TEST_EVENTNAME("to_string.fractional");
const string_convert_impl<Repres> impl{repres};
return impl.to_string_fractional(forward<T>(val));
}
Expand All @@ -751,6 +753,7 @@ namespace to_string_n{
typedef convert_state_t state_t;
template<numerical_representation Repres>
[[nodiscard]]T operator()(const string&str,const Repres&repres,convert_state_t&state)const noexcept{
ELC_TEST_EVENTNAME("from_string_get");
const string_convert_impl<Repres> impl{repres};
return impl.from_string_get<T>(str,state);
}
Expand All @@ -768,6 +771,7 @@ namespace to_string_n{
//单个字符
template<numerical_representation Repres>
[[nodiscard]]T operator()(const char_t&ch,const Repres&repres,convert_state_t&state)const noexcept{
ELC_TEST_EVENTNAME("from_string_get");
const string_convert_impl<Repres> impl{repres};
return impl.from_string_get<T>(ch,state);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct end_apply_string_data_t final:base_string_data_t<char_T>,instance_struct<
_used_size=p->_used_size;
_to_size=p->_to_size;
_m=move(p->_m);
_to=move(p->_to);
_to=p->_to;//不要使用移动语义:智能指针的移动语义基于swap,会导致p->_to自我指向,进而导致内存泄漏
}
}
void self_changed()noexcept{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct head_apply_string_data_t final:base_string_data_t<char_T>,instance_struct
_used_size=p->_used_size;
_to_size=p->_to_size;
_m=move(p->_m);
_to=move(p->_to);
_to=p->_to;//不要使用移动语义:智能指针的移动语义基于swap,会导致p->_to指向p,进而导致内存泄漏
}
}
void self_changed()noexcept{
Expand Down

0 comments on commit f1efb13

Please sign in to comment.