On 18 December 2015 at 10:37, Stefan Seefeld
On 18.12.2015 11:20, Nat Goodspeed wrote:
Am I overlooking a generic boost::make<something>() of this general form?
template class CLASS_TEMPLATE, typename... ARGS> CLASS_TEMPLATE
make(ARGS && ... args) { return CLASS_TEMPLATE (std::forward<ARGS>(args)...); } If that doesn't already exist... would it be useful to add (a less naive version) somewhere?
Given the small amount of code potentially to be reused, what would be the advantage of having a generic version ? The goal of abstraction should be clarity, but more often than not, generalizing code rips off not only unnecessary details but also its meaning, making the code harder, not easier, to understand.
I disagree. The make_* functions are just noise, and I'd love to see a generic one. While return type deduction has made it somewhat easier to write these functions, a generic one would be superior. Note: you cannot do a completely generic one, because you don't know whether to deduce type parameters or non-type parameters (such as for boost::array). An even better solution is a language change such as the one proposed in P0091R0 Template parameter deduction for constructors http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0091r0.html, but I don't know the status of that proposal. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com +1-847-691-1404