Is STL final?

1,549 views
Skip to first unread message

farid....@gmail.com

unread,
Apr 7, 2019, 9:11:17 AM4/7/19
to ISO C++ Standard - Discussion
Are std template classes inheritable in user code ?
Or should they be marked final?

regards,
FM.

Ville Voutilainen

unread,
Apr 7, 2019, 9:12:32 AM4/7/19
to std-dis...@isocpp.org
On Sun, 7 Apr 2019 at 16:11, <farid....@gmail.com> wrote:
>
> Are std template classes inheritable in user code ?

Yes.

> Or should they be marked final?

No, absolutely not, that would prevent useful wrapping techniques.

Farid Mehrabi

unread,
Apr 7, 2019, 9:32:40 AM4/7/19
to ISO C++ Standard - Discussion
Good. I was thinking after introduction of the keyword 'final' such code may become obsolete. Is there any specific explicit wording in the std docs about this?

در یکشنبه 7 آوریل 2019، ساعت 17:42:32 (UTC+4:30)، Ville Voutilainen نوشته:

Daniel Krügler

unread,
Apr 7, 2019, 9:39:53 AM4/7/19
to std-dis...@isocpp.org
Am So., 7. Apr. 2019 um 15:32 Uhr schrieb Farid Mehrabi
<farid....@gmail.com>:
>
> Good. I was thinking after introduction of the keyword 'final' such code may become obsolete. Is there any specific explicit wording in the std docs about this?
>

There is no specific wording, but we had in the past an issue about
that situation, which was resolved as NAD:

https://cplusplus.github.io/LWG/issue2113

There is no wording in the standard, that allows an implementation to
mark STL components as final, therefore any implementation that would
do that would be non-conforming.

- Daniel

Robert Haberlach

unread,
Apr 7, 2019, 9:43:15 AM4/7/19
to std-dis...@isocpp.org
No, it's by definition. See the header prototypes. 

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.

Nicol Bolas

unread,
Apr 7, 2019, 9:51:17 AM4/7/19
to ISO C++ Standard - Discussion


On Sunday, April 7, 2019 at 9:43:15 AM UTC-4, Columbo wrote:
No, it's by definition. See the header prototypes. 

More specifically, [derivation]/4 says:

> All types specified in the C++ standard library shall be non-final types unless otherwise specified.

Peter Sommerlad

unread,
Apr 7, 2019, 1:21:59 PM4/7/19
to std-dis...@isocpp.org
In my book, using final is always a mistake. If i were around when final and override were introduced, i would have been strongly against.

„Override“ is either checked anyway by compilers or displayed by IDEs.

In C++ i can not perceive any useful application of final, that would not require perfect foresight, which is typically not possible.

My cHF0.02

Peter

sent from a mobile device so please excuse strange words due to autocorrection.
Prof. Peter Sommerlad
peter.S...@hsr.ch
+41-79-432 23 32
Message has been deleted
Message has been deleted
Message has been deleted

Hyman Rosen

unread,
Apr 7, 2019, 5:05:57 PM4/7/19
to std-dis...@isocpp.org
On Sun, Apr 7, 2019 at 1:21 PM Peter Sommerlad <peter.s...@hsr.ch> wrote:
In my book, using final is always a mistake. If i were around when final and override were introduced, i would have been strongly against.

You're right about final but you're wrong about override.  Final is for the
optimizationists who want the compiler to avoid dispatching when it can.
 Override is for the programmers to be informed when someone upstream
changes the profile of a virtual function.  This has happened repeatedly,
for example, in clang's preprocessor interface, and without override, you
just notice that your code has stopped working without knowing why.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages