boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一个 C++ STL base type 的问题
相关主题
C++ template problem
Help C++ Template function link error .
请教template和factory有啥区别?
问一下这个cast在java里是怎么work的
good C++ open source project?
一个STL的问题
If using C++, please avoid the use of STL for these questio (转载)
Question in C++ complex number implementation
reading STL list implementation
qeustion about separation of interface and implementation in java
相关话题的讨论汇总
话题: stl话题: c++话题: template话题: base话题: class
进入Programming版参与讨论
1 (共1页)
s******s
发帖数: 505
1
C++ STL list 的实现:
为什么先写一个base类型,然后再从base继承出主要类型,比如list?
这个base似乎在任何别的地方都用不到。
这样做,从编程方法上有什么优越之处?谢谢!
t****t
发帖数: 6806
2
maybe, in case you want to have any specialized implementation?

【在 s******s 的大作中提到】
: C++ STL list 的实现:
: 为什么先写一个base类型,然后再从base继承出主要类型,比如list?
: 这个base似乎在任何别的地方都用不到。
: 这样做,从编程方法上有什么优越之处?谢谢!

s******s
发帖数: 505
3

The header file noted that the purpose was to "split into" a
non-template base and a template type node. However, I fail
to see the point of doing this, since the STL list is only used and
known as a template class.

【在 t****t 的大作中提到】
: maybe, in case you want to have any specialized implementation?
t****t
发帖数: 6806
4
if the base class is non-template, then it makes perfect sense --- the non-
template part can be pre-compiled. i thought you are referring to libstdc++
(in which case the base class is also a template).

【在 s******s 的大作中提到】
:
: The header file noted that the purpose was to "split into" a
: non-template base and a template type node. However, I fail
: to see the point of doing this, since the STL list is only used and
: known as a template class.

X****r
发帖数: 3557
5
For each type as the parameter of this node class, the compiler
needs to generate a separate piece code for each instantiated class.
By moving common logic from the template node class to a
non-template base class, the corresponding code no longer get
duplicated, resulting smaller binaries.

【在 s******s 的大作中提到】
:
: The header file noted that the purpose was to "split into" a
: non-template base and a template type node. However, I fail
: to see the point of doing this, since the STL list is only used and
: known as a template class.

s******s
发帖数: 505
6

Thank you.

【在 X****r 的大作中提到】
: For each type as the parameter of this node class, the compiler
: needs to generate a separate piece code for each instantiated class.
: By moving common logic from the template node class to a
: non-template base class, the corresponding code no longer get
: duplicated, resulting smaller binaries.

s******s
发帖数: 505
7

+
Now I am confused. Sorry I don't know C++ well.
I thought STL was part of libstdc++.

【在 t****t 的大作中提到】
: if the base class is non-template, then it makes perfect sense --- the non-
: template part can be pre-compiled. i thought you are referring to libstdc++
: (in which case the base class is also a template).

t****t
发帖数: 6806
8
libstdc++ is one particular (gcc's) implementation of STL

【在 s******s 的大作中提到】
:
: +
: Now I am confused. Sorry I don't know C++ well.
: I thought STL was part of libstdc++.

s******s
发帖数: 505
9

I see, thank you.

【在 t****t 的大作中提到】
: libstdc++ is one particular (gcc's) implementation of STL
1 (共1页)
进入Programming版参与讨论
相关主题
qeustion about separation of interface and implementation in java
请教C++中的unordered_set
Python problem on 64 bit Linux
请问大家一个eclipse CDT的问题 (转载)
stl: How to implement map idea with vector in stl ?
how to implement binary tree efficiently?
请问STL里有没有类似dot_product的算法
some interview questions
How is map implemented in STL?
请问这道题怎么解决?
相关话题的讨论汇总
话题: stl话题: c++话题: template话题: base话题: class