Summary of issue:
Example: std::make_unique expects to be passed a type as an explicit template parameter. We probably want a call such as Cpp.std.make_unique(MyType, arg1, arg2) to construct it from arg1, arg2. If so, how do we achieve that?
Details:
Probably the most obvious approach would be to say: if a template parameter is not deducible, then it must be explicitly specified in a call. That works for make_unique, and probably works fairly well in general, except for two things:
make_unique is overloaded. How should we handle the case where different overloads have different sets of non-deducible template parameters? Perhaps we could just reject such a call and ask for some explicit syntax to be used to indicate what the template arguments are.
- While this may be a good default, it doesn't allow us to perform any call that's possible in C++, and doesn't give a way to override the default. One example where this comes up in practice in C++ is calls to
std::min, where a deduced template argument is often fine, but sometimes you would want to call (eg) std::min<int64_t> because deduction would otherwise fail or pick the wrong type.
So perhaps we should additionally have some mechanism to explicitly specify the template arguments. If it's rarely used, I suppose it might be OK for it to be a little verbose. For example, we could use something like:
Cpp.std.min(Cpp.template(i32), 1, 2)
(where Cpp.template wraps a tuple of arguments so that the C++ call machinery knows to treat them as template arguments).
Any other information that you want to share?
No response
Summary of issue:
Example:
std::make_uniqueexpects to be passed a type as an explicit template parameter. We probably want a call such asCpp.std.make_unique(MyType, arg1, arg2)to construct it fromarg1, arg2. If so, how do we achieve that?Details:
Probably the most obvious approach would be to say: if a template parameter is not deducible, then it must be explicitly specified in a call. That works for
make_unique, and probably works fairly well in general, except for two things:make_uniqueis overloaded. How should we handle the case where different overloads have different sets of non-deducible template parameters? Perhaps we could just reject such a call and ask for some explicit syntax to be used to indicate what the template arguments are.std::min, where a deduced template argument is often fine, but sometimes you would want to call (eg)std::min<int64_t>because deduction would otherwise fail or pick the wrong type.So perhaps we should additionally have some mechanism to explicitly specify the template arguments. If it's rarely used, I suppose it might be OK for it to be a little verbose. For example, we could use something like:
Cpp.std.min(Cpp.template(i32), 1, 2)(where
Cpp.templatewraps a tuple of arguments so that the C++ call machinery knows to treat them as template arguments).Any other information that you want to share?
No response