Variadic template templates and perfect forwarding

前端 未结 3 1031
北恋
北恋 2020-12-07 16:24

This question on the object generator pattern got me thinking about ways to automate it.

Essentially, I want to automate the creation of functions like std::ma

3条回答
  •  一个人的身影
    2020-12-07 17:14

    This is quite wrong- take make_shared, for example. The point of make_shared is that there are run-time efficiency savings for using it. But what would happen if I tried to use make? Don't think that would quite work out. Or how about types where only some of the constructor arguments are template arguments, and the rest aren't? For example, make(other_vector.begin(), other_vector.end()); - the types of the iterators don't participate, but you pass them in anyway.

    It's impossible to write a generic make function.

    As for the Standard, well, it could easily have been removed since then. You'd have to check the FDIS.

提交回复
热议问题