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

cpp: define isl::managed_copy() overload #9

Closed
ftynse opened this issue Aug 1, 2017 · 5 comments
Closed

cpp: define isl::managed_copy() overload #9

ftynse opened this issue Aug 1, 2017 · 5 comments

Comments

@ftynse
Copy link
Member

ftynse commented Aug 1, 2017

I found myself writing
isl::manage(isl_whatever_copy(o)); // manage releases!
multiple times.

Can we generate an overloaded function

isl::whatever managed_copy(__isl_keep isl_whatever *w) {
  return isl::manage(isl_whatever_copy(w));
}

as a shortcut for these cases?

@ftynse
Copy link
Member Author

ftynse commented Aug 1, 2017

While the idea of the C++ interface is not to use raw pointers, other isl-dependent libraries (read ppcg) may use raw pointers and feature no C++ interface.

@tobiasgrosser
Copy link
Member

Sounds very reasonable. Should be a rather simple change and this is indeed a pattern that arises often. Would be glad to see a PR.

@ftynse
Copy link
Member Author

ftynse commented Aug 1, 2017

This hack may work, but it will break the consistency of __isl_keep/__isl_take because manage is __take.

template <typename T>
auto managed_copy(__isl_keep T t) -> decltype(isl::manage(t)) {
  auto x = isl::manage(t);
  auto copy = x;
  x.release();
  return copy;
}

@tobiasgrosser
Copy link
Member

I would just extend the generator. Should only be a couple of lines and
can follow precisely the pattern isl::manage is generated.

Best,
Tobias

@tobiasgrosser tobiasgrosser changed the title Define isl::managed_copy() overload cpp: define isl::managed_copy() overload Aug 7, 2017
@tobiasgrosser
Copy link
Member

This issue has been resolved.

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

2 participants