C++ Technical Report 1 (TR1) is the common name for ''ISO/IEC TR 19768, C++ Library Extensions'', which is a document that proposed additions to the
C++ standard library
The C standard library, sometimes referred to as libc, is the standard library for the C programming language, as specified in the ISO C standard.ISO/ IEC (2018). '' ISO/IEC 9899:2018(E): Programming Languages - C §7'' Starting from the origina ...
for the
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 ...
language standard. The additions include
regular expression
A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of characters that specifies a match pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s,
smart pointer
In computer science, a smart pointer is an abstract data type that simulates a pointer while providing added features, such as automatic memory management or bounds checking. Such features are intended to reduce bugs caused by the misuse of p ...
s,
hash table
In computer science, a hash table is a data structure that implements an associative array, also called a dictionary or simply map; an associative array is an abstract data type that maps Unique key, keys to Value (computer science), values. ...
s, and
random number generator
Random number generation is a process by which, often by means of a random number generator (RNG), a sequence of numbers or symbols is generated that cannot be reasonably predicted better than by random chance. This means that the particular ou ...
s. 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
C++11 is a version of a joint technical standard, ISO/IEC 14882, by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), for the C++ programming language. C++11 replaced the prior vers ...
. 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 a
Draft Technical Report on C++ Library Extensions then published in 2007 as an ISO/IEC standard a
Overview
Compilers
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
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
C++11 is a version of a joint technical standard, ISO/IEC 14882, by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), for the C++ programming language. C++11 replaced the prior vers ...
. 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
In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.
Namespaces ...
to distinguish them from the then-current standard library.
Components
TR1 includes the following components:
General utilities
Reference wrapper – enables passing
references
A reference is a relationship between Object (philosophy), objects in which one object designates, or acts as a means by which to connect to or link to, another object. The first object in this relation is said to ''refer to'' the second object. ...
, 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 class
reference_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 (for a constant reference
cref
is used).
Wrapper references are useful above all for template functions, when argument deduction would not deduce a reference (e.g. when forwarding arguments):
#include
#include
void f( int &r )
template< class Funct, class Arg >
void g( Funct f, Arg t )
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 pointer
*
weak_ptr
– a variant of
shared_ptr
that doesn't increase the reference count
The proposal is based on Boost Smart Pointer library.
Function objects
These four modules are added to the
header file:
Polymorphic function wrapper (
function
) – can store any callable function (function pointers, member function pointers, and function objects) 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 (
bind
) – can bind any parameter
parameters
A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
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 (
result_of
) – determines the type of a call expression.
Member functions (
mem_fn
) – 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
Type may refer to:
Science and technology Computing
* Typing, producing text via a keyboard, typewriter, etc.
* Data type, collection of values used for computations.
* File type
* TYPE (DOS command), a command to display contents of a file.
* Ty ...
. The proposal is based on Boost Type Traits library.
Numerical facilities
Random number generation
* new
header file –
variate_generator
,
mersenne_twister
The Mersenne Twister is a general-purpose pseudorandom number generator (PRNG) developed in 1997 by and . Its name derives from the choice of a Mersenne prime as its period length.
The Mersenne Twister was created specifically to address most of ...
,
poisson_distribution
In probability theory and statistics, the Poisson distribution () is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time if these events occur with a known const ...
, etc.
* utilities for generating random numbers using any of several
Pseudorandom number generators, engines, and
probability distributions
In probability theory and statistics, a probability distribution is a function that gives the probabilities of occurrence of possible events for an experiment. It is a mathematical description of a random phenomenon in terms of its sample spac ...
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
/
header files –
beta
Beta (, ; uppercase , lowercase , or cursive ; or ) is the second letter of the Greek alphabet. In the system of Greek numerals, it has a value of 2. In Ancient Greek, beta represented the voiced bilabial plosive . In Modern Greek, it represe ...
,
legendre
, etc.
These functions will likely be of principal interest to programmers in the engineering and scientific disciplines.
The following table shows all 23 special functions described in TR1.
Each function has two additional variants. Appending the suffix ‘f’ or ‘l’ to a function name gives a function that operates on
float
or
long double
values respectively. For example:
float sph_neumannf( unsigned n, float x ) ;
long double sph_neumannl( unsigned n, long double x ) ;
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
Type may refer to:
Science and technology Computing
* Typing, producing text via a keyboard, typewriter, etc.
* Data type, collection of values used for computations.
* File type
* TYPE (DOS command), a command to display contents of a file.
* Ty ...
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
, and
unordered_multimap
classes, analogous to
set
,
multiset
,
map
, and
multimap
, respectively
** unfortunately,
unordered_set
and
unordered_multiset
cannot be used with the
set_union
,
set_intersection
,
set_difference
,
set_symmetric_difference
, and
includes
standard library functions, which work for
set
and
multiset
* new implementation, not derived from an existing library, not fully API compatible with existing libraries
* like all
hash table
In computer science, a hash table is a data structure that implements an associative array, also called a dictionary or simply map; an associative array is an abstract data type that maps Unique key, keys to Value (computer science), values. ...
s, often provide
constant time
In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
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
C (''pronounced'' '' – like the letter c'') is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of ...
, 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 as
, , , etc. These changes help to bring C++ more in line with the C99
C99 (previously C9X, formally ISO/IEC 9899:1999) is a past version of the C programming language open standard. It extends the previous version ( C90) with new features for the language and the standard library, and helps implementations mak ...
version of the C standard (not all parts of C99 are included in TR1).
Technical 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 programmer
TR2 call for proposals
Some of the proposals included:
* Thread
* The Asio C++ library (networkin
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2175.pdf ]).
* Signals/Slot
[sigc] Proposal for standardization in C++ Library TR2
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2086.pdf ]
* Filesystem Librar
Filesystem Library for TR2
– Based on the Boost Filesystem Library, for query/manipulation of paths, files and directories.
* Boost Any Librar
* Lexical Conversion Librar
* New String Algorithm
* Toward a More Complete Taxonomy of Algebraic Properties for Numeric Libraries in TR
ISO/IEC JTC1/SC22/WG21 - Papers 2008
* Adding heterogeneous comparison lookup to associative containers for TR
After the call was issued for proposals for TR2, ISO procedures were changed, so there will not be a TR2. Instead, enhancements to C++ will be published in a number of Technical Specifications. Some of the proposals listed above are already included in the C++ standard or in draft versions of the Technical Specifications.
See also
* C++11
C++11 is a version of a joint technical standard, ISO/IEC 14882, by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), for the C++ programming language. C++11 replaced the prior vers ...
, standard for the C++ programming language; the library improvements were based on TR1
* C11 (C standard revision)
C11 (previously C1X, formally ISO/IEC 9899:2011) is a past standard for the C programming language. It replaced C99 (standard ISO/IEC 9899:1999) and has been superseded by C17 (standard ISO/IEC 9899:2018). C11 mainly standardizes features al ...
, a revision of the C standard which incorporated some features proposed in TR1
* Boost library
Boost is a set of library (computing), libraries for the C++ programming language that provides support for tasks and structures such as linear algebra, pseudorandom number generator, pseudorandom number generation, multithreading, image proces ...
, a large collection of portable C++ libraries, several of which were included in TR1
* Standard Template Library
The Standard Template Library (STL) is a software library originally designed by Alexander Stepanov for the C++ programming language that influenced many parts of the C++ Standard Library. It provides four components called ''algorithms'', '' ...
, part of the current C++ Standard Library
References
Sources
*
*
* {{cite book , first = Peter , last = Becker , title = The C++ Standard Library Extensions: A Tutorial and Reference , year = 2006 , publisher = Addison-Wesley Professional , isbn = 0-321-41299-0
External links
Scott Meyers' Effective C++: TR1 Information
– contains links to the TR1 proposal documents which provide background and rationale for the TR1 libraries.
C++ Standard Library