diff --git a/include/cinatra/string_resize.hpp b/include/cinatra/string_resize.hpp index fa577ff6..1913087a 100644 --- a/include/cinatra/string_resize.hpp +++ b/include/cinatra/string_resize.hpp @@ -18,39 +18,30 @@ inline void resize(std::string& str, std::size_t sz) { inline void resize(std::string& str, std::size_t sz) { str.resize(sz); } #else -#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) -template +template class string_thief { public: - friend void string_set_length_hacker(std::string& bank, std::size_t sz) { - (bank.*p)(sz); - } -}; -#elif defined(_MSVC_STL_VERSION) -template -class string_thief { - public: - friend void string_set_length_hacker(std::string& bank, std::size_t sz) { - (bank.*p)._Myval2._Mysize = sz; + 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 + (self.*func_ptr)(sz); +#endif } }; -#endif #if defined(__GLIBCXX__) // libstdc++ -template class string_thief; #elif defined(_LIBCPP_VERSION) -template class string_thief; #elif defined(_MSVC_STL_VERSION) -template class string_thief; #endif -#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) || \ - defined(_MSVC_STL_VERSION) -void string_set_length_hacker(std::string& bank, std::size_t sz); -#endif +void string_set_length_hacker(std::string&, std::size_t); inline void resize(std::string& str, std::size_t sz) { #if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) || \