mirror of https://github.com/swig/swig
Fixes for deprecated std::basic_string::reserve()
This commit is contained in:
parent
675c94c575
commit
ffbde7a132
|
@ -7,6 +7,23 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-07-30: wsfulton
|
||||
C++20 has deprecated std::basic_string<>::reserve() and the C++11 method
|
||||
std::basic_string<>::shrink_to_fit() is a replacement that can be used.
|
||||
std_string.i and std_wstring.i provided wrappers for reserve with the following
|
||||
template instantiations:
|
||||
|
||||
%template(string) std::basic_string<char>;
|
||||
%template(wstring) std::basic_string<wchar_t>;
|
||||
|
||||
The reserve method is no longer wrapped, however the shrink_to_fit() method
|
||||
can be used as an alternative from the target language (the generated wrappers
|
||||
call reserve() instead if C++<=20).
|
||||
|
||||
Note that std::basic_string<>::reserve(size_t n) is still wrapped unchanged.
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
2022-07-30: wsfulton
|
||||
[Tcl] Add support for std::unique_ptr in std_unique_ptr.i.
|
||||
Add support for std::auto_ptr in std_auto_ptr.i.
|
||||
|
|
|
@ -15,6 +15,11 @@ if li_std_string_extra.test_value(x) != x:
|
|||
if li_std_string_extra.test_const_reference(x) != x:
|
||||
raise RuntimeError("bad string mapping")
|
||||
|
||||
s = li_std_string_extra.string("1234567890")
|
||||
size = s.size()
|
||||
if size != 10:
|
||||
raise "Incorrect size"
|
||||
s.shrink_to_fit()
|
||||
|
||||
s = li_std_string_extra.string("he")
|
||||
#s += "ll"
|
||||
|
|
|
@ -55,7 +55,16 @@ namespace std {
|
|||
|
||||
size_type capacity() const;
|
||||
|
||||
void reserve(size_type __res_arg = 0);
|
||||
void reserve(size_type __res_arg);
|
||||
%extend {
|
||||
void shrink_to_fit() {
|
||||
%#if __cplusplus >= 202002L
|
||||
self->shrink_to_fit();
|
||||
%#else
|
||||
self->reserve();
|
||||
%#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Modifiers:
|
||||
|
|
Loading…
Reference in New Issue