C++ Technical Report 1
C++ Technical Report 1 is the common name for ISO/IEC TR 19768, C++ Library Extensions, which is a document that proposed additions to the C++ standard library for the C++03 language standard. The additions include regular expressions, smart pointers, hash tables, and random number generators. TR1 was not a standard itself, but rather a draft document. However, most of its proposals became part of the later official standard, C++11. Before C++11 was standardized, vendors used this document as a guide to create extensions. The report's goal was "to build more widespread existing practice for an expanded C++ standard library".
The report was first circulated in draft form in 2005 as, then published in 2007 as an ISO/IEC standard as .
Overview
Compilers did not need to include the TR1 components in order to conform to the C++ standard, because TR1 proposals were not part of the standard itself, only a set of possible additions that were still to be ratified. However, most of TR1 was available from Boost, and several compiler/library distributors implemented all or some of the components. TR1 is not the complete list of additions to the library that appeared in C++11. For example, C++11 includes a thread support library that is not available in TR1.The new components were defined in the
std::tr1 namespace to distinguish them from the then-current standard library.Components
TR1 includes the following components:General utilities
Reference wrapper – enables passing references, rather than copies, into algorithms or function objects. The feature was based on Boost.Ref. A wrapper reference is obtained from an instance of the template classreference_wrapper. Wrapper references are similar to normal references of the C++ language. To obtain a wrapper reference from any object the template class ref is used.Wrapper references are useful above all for template functions, when argument deduction would not deduce a reference :
- include
- include
template
void g
int main
Smart pointers – adds several classes that simplify object lifetime management in complex cases. Three main classes are added:
shared_ptr– a reference-counted smart pointerweak_ptr– a variant ofshared_ptrthat doesn't increase the reference count
Function objects
These four modules are added to the header file:Polymorphic function wrapper – can store any callable function that uses a specified function call signature. The type does not depend on the kind of the callable used. Based on Boost.Function
Function object binders – can bind any parameter parameters to function objects. Function composition is also allowed. This is a generalized version of the standard
std::bind1st and std::bind2nd bind functions. The feature is based on Boost Bind library.Function return types – determines the type of a call expression.
Member functions – enhancement to the standard
std::mem_fun and std::mem_fun_ref. Allows pointers to member functions to be treated as function objects. Based on Boost Mem Fn library.Metaprogramming and type traits
There is now header file that contains many useful trait meta-templates, such as is_pod, has_virtual_destructor, remove_extent, etc. It facilitates metaprogramming by enabling queries on and transformation between different types. The proposal is based on Boost Type Traits library.Numerical facilities
Random number generation
- new
header file –variate_generator,mersenne_twister,poisson_distribution, etc. - utilities for generating random numbers using any of several Pseudorandom number generators, engines, and probability distributions
Mathematical special functions
Some features of TR1, such as the mathematical special functions and certain C99 additions, are not included in the Visual C++ implementation of TR1.The Mathematical special functions library was not standardized in C++11.
- additions to the
/
! Beta function
! Complete elliptic integral of the first kind
! Complete elliptic integral of the second kind
! Complete elliptic integral of the third kind
! Confluent hypergeometric functions
! Regular modified cylindrical Bessel functions
! Cylindrical Bessel functions of the first kind
! Irregular modified cylindrical Bessel functions
! Cylindrical Neumann functions
Cylindrical Bessel functions of the second kind
! Incomplete elliptic integral of the first kind
! Incomplete elliptic integral of the second kind
! Incomplete elliptic integral of the third kind
! Exponential integral
! Hermite polynomials
! Hypergeometric series
! Laguerre polynomials
! Legendre polynomials
! Riemann zeta function
! Spherical Bessel functions of the first kind
! Spherical associated Legendre functions
! Spherical Neumann functions
Spherical Bessel functions of the second kind
Containers
Tuple types
- new
header file –tuple - based on Boost Tuple library
- vaguely an extension of the standard
std::pair - fixed size collection of elements, which may be of different types
Fixed size array
- new
header file –array - taken from Boost Array library
- as opposed to dynamic array types such as the standard
std::vector
Hash tables
- new
,<unordered_map>header files - they implement the
unordered_set,unordered_multiset,unordered_map, andunordered_multimapclasses, analogous toset,multiset,map, andmultimap, respectively - * unfortunately,
unordered_setandunordered_multisetcannot be used with theset_union,set_intersection,set_difference,set_symmetric_difference, andincludesstandard library functions, which work forsetandmultiset - new implementation, not derived from an existing library, not fully API compatible with existing libraries
- like all hash tables, often provide constant time lookup of elements but the worst case can be linear in the size of the container
Regular expressions
- new
header file –regex,regex_match,regex_search,regex_replace, etc. - based on Boost RegEx library
- pattern matching library
C compatibility
C++ is designed to be compatible with the C programming language, but is not a strict superset of C due to diverging standards. TR1 attempts to reconcile some of these differences through additions to various headers in the C++ library, such asTechnical Report 2
In 2005, a request for proposals for a TR2 was made with a special interest in Unicode, XML/HTML, Networking and usability for novice programmers..Some of the proposals included:
- Threads
- The Asio C++ library.
- Signals/Slots
- Filesystem Library – Based on the Boost Filesystem Library, for query/manipulation of paths, files and directories.
- Boost Any Library
- Lexical Conversion Library
- New String Algorithms
- Toward a More Complete Taxonomy of Algebraic Properties for Numeric Libraries in TR2
- Adding heterogeneous comparison lookup to associative containers for TR2