Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must a C++ Standard Library be implemented in C++?

  1. Must a conforming C++ Standard Library Implementation be implemented in C++?
  2. If not, is it allowed to do magic things that are not doable in pure C++ & Standard Library & some implementation defined behaviour?

  • I am aware that there are parallel implementations that rely on extensions (in pre C++11 at least), but are they really conforming?
  • I couldn't find any requirement in the standard, but maybe my standard-fu is weak today
like image 377
Sebastian Mach Avatar asked Feb 06 '12 16:02

Sebastian Mach


1 Answers

There is no requirement at all how the standard C++ library (or the standard C library for that matter) is implemented. All the library needs to achieve is to implement the documented and specified interface. How this is done is entirely up to the implementation. Part of standard libraries are often implemented by the compiler in some magic way and in C++2011 there are several interfaces which actually cannot be implemented using standard C++2011 language facilities! Primarily this is true for some of the traits in <type_traits> but there are other things.

Just for the reference: how C++ is implemented and what it actually really means to conform to the standard is held extremely vague. The relevant clause is 1.4 [intro.compliance]. It merely speaks about diagnostics being issued and what a program has to do, constraint to resource limitations, however.

like image 64
Dietmar Kühl Avatar answered Sep 20 '22 05:09

Dietmar Kühl