Skip to content

Commit

Permalink
resize compatible with gcc4.x (qicosmos#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Oct 9, 2023
1 parent 2f8d126 commit 2422dfe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/cinatra/string_resize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,24 @@ class string_thief {
friend void string_set_length_hacker(std::string& self, std::size_t sz) {
#if defined(_MSVC_STL_VERSION)
(self.*func_ptr)._Myval2._Mysize = sz;
#else
#if (_GLIBCXX_USE_CXX11_ABI == 0) && defined(__GLIBCXX__)
(self.*func_ptr)()->_M_set_length_and_sharable(sz);
#else
(self.*func_ptr)(sz);
#endif
#endif
}
};

#if defined(__GLIBCXX__) // libstdc++
#if (_GLIBCXX_USE_CXX11_ABI == 0)
template class string_thief<decltype(&std::string::_M_rep),
&std::string::_M_rep>;
#else
template class string_thief<decltype(&std::string::_M_set_length),
&std::string::_M_set_length>;
#endif
#elif defined(_LIBCPP_VERSION)
template class string_thief<decltype(&std::string::__set_size),
&std::string::__set_size>;
Expand Down

0 comments on commit 2422dfe

Please sign in to comment.