Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] Support for std::vector<std::unique_ptr<TYPE>> #2880

Open
leeroyka opened this issue Apr 17, 2024 · 0 comments
Open

[C#] Support for std::vector<std::unique_ptr<TYPE>> #2880

leeroyka opened this issue Apr 17, 2024 · 0 comments

Comments

@leeroyka
Copy link

Vector generation doesn't fully use move semantics for std::unique_ptr

swig 4.3.0 (7800b52)
I tried to compile this code

%include <std_vector.i>
%include <std_unique_ptr.i>

%unique_ptr(Test);

%inline %{
class Test
{
public:
    Test() = default;
};
%}

%template(TestVector) std::vector<std::unique_ptr<Test>>;

%inline %{
#include <memory>
#include <vector>

std::vector<std::unique_ptr<Test>> createVector() {
    std::vector<std::unique_ptr<Test>> vec;
    return vec;
}
%}
error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Test; _Dp = std::default_delete<Test>]’
  461 |           return (*self)[index];
error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Test; _Dp = std::default_delete<Test>]’
  473 |           (*self)[index] = val;
required from here
/usr/include/c++/9/ext/new_allocator.h:146:4: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Test; _Dp = std::default_delete<Test>]’
  146 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant