Why is it not good to use recursive inheritance for std::tuple implementations?

后端 未结 3 1149
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 05:14

In this question, Howard Hinnant said

Some implementations of std::tuple use recursive inheritance. But the good ones don\'t. ;-)

3条回答
  •  天命终不由人
    2020-11-29 06:08

    One reason not to use a chain of base classes is that there is no chain of constructors involved: the arguments are directly forwarded to the appropriate subobject. Also, it seems that a non-recursive implementation puts a lot less strain on the compiler and creates a lot less [internal] symbols. Not to mention that it is actually easier not to a chain of base classes.

提交回复
热议问题