Enhanced std::map for non-default constructible types changes entry

Improve testcase too.
This commit is contained in:
William S Fulton 2023-09-18 19:20:21 +01:00
parent 8d3f5e75d0
commit 7f63ea6b2f
2 changed files with 7 additions and 0 deletions

View File

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (in progress)
===========================
2023-09-18: christophe-calmejane
#2631 C++17 std::map fix for values that are not default constructible.
Enhancements for all target languages except Python and Ruby.
2023-06-30: wsfulton
#2640 Fix syntax error parsing an expression which calls a function
with no parameters within additional brackets.

View File

@ -3,13 +3,16 @@
%include <std_map.i>
%ignore NoDefaultConstructorStruct::operator<;
%inline %{
struct NoDefaultConstructorStruct final
{
int value{0};
NoDefaultConstructorStruct(int v) : value(v) {}
bool operator<(const NoDefaultConstructorStruct& other) const { return value < other.value; }
};
using NoDefaultConstructorStructMap = std::map<int, NoDefaultConstructorStruct>;
%}
//%template(PairIntNoDefaultConstructorStruct) std::pair<const int, NoDefaultConstructorStruct>;
%template(NoDefaultConstructorStructMap) std::map<int, NoDefaultConstructorStruct>;