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

Conversion from different instantiation of unique_resource. #9

Open
ghost opened this issue Oct 29, 2018 · 0 comments
Open

Conversion from different instantiation of unique_resource. #9

ghost opened this issue Oct 29, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2018

unique_resource proposal fills a sore gap in the C++ automatic resource management. I am using an incarnation of it in my projects and recently I noticed the following usability issue when going through the factory functions. Say, one defines a managed resource at some scope as:

using T = unique_resource< int, std::function< void(int) > >;

followed by an instantiation, e.g.:

T t = make_unique_resource_checked (0, 0, (void(*)(int))0);

In the current specification the conversion is prohibited as the deduced type does not match T. This makes for some awkward gymnastics where one is forced to explicitly give the template arguments to the factory function but it could be avoided by a template move assign operator and move constructor (I'll add one shortly in the implementation I use). I am not sure if that fits the original purpose of the design or is generally desirable but I was wondering if this ever came up in the discussions you had during your meetings.

@ghost ghost changed the title Conversion from different instantiation. Conversion from different instantiation of unique_resource. Oct 29, 2018
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

0 participants