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

Is there a way to expose a C++ class that is itself a wrapper on std::shared_ptr? #1359

Open
lenianiva opened this issue Jul 3, 2024 · 0 comments

Comments

@lenianiva
Copy link

lenianiva commented Jul 3, 2024

For example, consider a class like this:

namespace internal {
  class Result;
}
class Result {
public:
  Result();
private:
  std::shared_ptr<internal::Result> d_result;
};

Is there a way to expose this in Rust in a way equivalent to

struct Result {
  p: SharedPtr<Opaque>,
}

An implementation like this example gives the error "type Result should be trivially move constructible and trivially destructible in C++ to be used as a return value of newResult in Rust"

I cannot change the C++ header and I don't want to add another layer of indirection by wrapping Result as an opaque class in a shared pointer.

@lenianiva lenianiva changed the title Is there a way to expose a C++ class that is itself a wrapper? Is there a way to expose a C++ class that is itself a wrapper on std::shared_ptr? Jul 3, 2024
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