C++03

C++03 is a version of the ISO/IEC 14882 standard for the C++ programming language. It is defined by two standards organizations, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC), in standard ISO/IEC 14882:2003.

C++03 replaced the prior C++98 standard. C++03 was later replaced by C++11. C++03 was primarily a bug fix release for the implementers to ensure greater consistency and portability. This revision addressed 92 core language defect reports, 125 library defect reports, and included only one new language feature: value initialization.

Among the more noteworthy defect reports addressed by C++03 was the library defect report 69, whose resolution added the requirement that elements in a vector are stored contiguously. This codifies the common expectation that a C++ std::vector object uses a memory layout similar to an array. While most implementations satisfied this expectation, it was not required by C++98.

One of the most infamous features introduced in C++03 was exported templates, which used the export keyword on a template declaration. An "exported template" is essentially a class template whose static data members and non-inline methods are exported; this essentially allowed a template's declaration to be separated from its implementation. It must be marked by the keyword export. What distinguishes an "exported template" is the fact that it does not need to be defined in a translation unit that uses the template. Because this feature was so difficult to implement (the only compiler known to have ever provided a complete implementation was Comeau C/C++), this feature was removed in C++11.

File1.cpp:

#include <iostream>

static void trace() {
    std::cout << "File 1" << std::endl;
}

export template <typename T>
T min(const T& x, const T& y);

int main() {
    trace();
    std::cout << min(2, 3) << std::endl;
}

File2.cpp:

#include <iostream>

static void trace() {
    std::cout << "File 2" << std::endl;
}

export template <typename T>
T min(const T& x, const T& y) {
    trace();
    return a < b ? a : b;
}

With the introduction of modules in C++20, the keyword export was re-purposed to mean exporting a symbol as accessible from an imported module. The compilation speed benefits intended to be offered by exported templates are offered by modules anyway, making the feature essentially obsolete and superseded by modules.

See also

References

  1. ↑ "Bjarne Stroustrup's FAQ – What is the difference between C++98 and C++03?". Bjarne Stroustrup's homepage. Archived from the original on February 6, 2016.
  2. ↑ "C++ Standard Core Language Issue Index by Status: Issues with "TC1" Status". open-std.org. Archived from the original on 2022-09-11. Retrieved 2022-09-20.
  3. ↑ "C++ Standard Library Issues List: TC1 (125 issues)". Archived from the original on 2018-07-21. Retrieved 2016-05-30.
  4. ↑ "Value initialization", C++ reference (wiki), archived from the original on 2018-05-27, retrieved 2016-05-30
  5. ↑ "C++ Standard Library Defect Report List: 69. Must elements of a vector be contiguous?". Archived from the original on 2018-07-19. Retrieved 2016-05-30.
  6. ↑ Herb, Sutter (2002). More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions. Boston: Pearson Education, Inc. p. 48. ISBN 0-201-70434-X. Archived from the original on 2022-09-21. Retrieved 2022-09-20.
  7. ↑ "Export Overview". comeaucomputing.com. Comeau Computing. Archived from the original on 2 June 2003.
  8. ↑ "Exported Template Overview". comeaucomputing.com. Comeau Computing. Archived from the original on 22 April 2003.