- C++ Technical Report 1
C++ Technical Report 1 (TR1) is the common name for ISO/IEC TR 19768, C++ Library Extensions, which is a document proposing additions to the
C++ standard library . The additions includeregular expression s,smart pointer s,hash table s, andrandom number generator s. TR1 is not a standard itself; formally it's a draft document. However, most of its proposals are likely to become part of the next official standard. In the meantime, vendors can use this document as a guide to create extensions. The report's goal is "to build more widespread existing practice for an expanded C++ standard library."Overview
Compilers need not include the TR1 components to be conforming, as the TR1 proposals are not yet officially part of the standard. Much of it is available from Boost, and several compiler/library distributors currently implement all or part of the components.TR1 is not a complete list of additions to the library that will appear in the next standard; for example, the next standard,
C++0x , may include support for threading. There is also a second technical report, TR2, planned for publishing after C++0x [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1810.html] .The new components are in the
std::tr1
namespace to distinguish them from the current standard library.Components
TR1 includes the following components:
General Utilities
Reference Wrapper
* lifted from Boost.Ref [http://www.boost.org/doc/html/ref.html]
* additions to theheader file -cref
,ref
,reference_wrapper
* enables passing references, rather than copies, into algorithms or function objectsA 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 classref
is used (for a constant referencecref
is used).Wrapper references are useful above all for template functions, when argument deduction would not deduce a reference (e.g. when forwarding arguments):
mart Pointers
* based on Boost Smart Pointer library [http://www.boost.org/libs/smart_ptr/smart_ptr.htm]
* additions to the
header file -shared_ptr
,weak_ptr
, etc
* utility for memory management and exception safety using theResource Acquisition Is Initialization (RAII) idiomFunction Objects
These four modules are added to the
header file:Polymorphic Function Wrapper
*
function
* based on Boost.Function [http://www.boost.org/doc/html/function.html]
* stores all callables (function pointers, member function pointers, and function objects) that use a specified function call signature. The specific type of callable object is not required.Function Object Binders
*
bind
* taken from Boost Bind library [http://www.boost.org/libs/bind/bind.html]
* generalized version of the standardstd::bind1st
andstd::bind2nd
* binds parameters to function objects, and allows for function composition.Function Return Types
*
result_of
* taken from Boost
* determines the type of a call expressionmem_fn
*
mem_fn
* based on Boost Mem Fn library [http://www.boost.org/libs/bind/mem_fn.html]
* enhancement to the standardstd::mem_fun
andstd::mem_fun_ref
* allowspointers to member functions to be treated as function objectsMetaprogramming and Type Traits
* new
header file -is_pod
,has_virtual_destructor
,remove_extent
, etc
* based on Boost Type Traits library [http://www.boost.org/doc/html/boost_typetraits.html]
* facilitates metaprogramming by enabling queries on and transformation between different typesNumerical Facilities
Random Number Generation
* new
header file -variate_generator
,
,mersenne twister
, etcpoisson distribution
* utilities for generating random numbers using various engines andprobability distributions Mathematical Functions
Some features of TR1, such as the mathematical functions and certain C99 additions, are not included in the Visual C++ implementation of TR1.
* additions to the
/
header files -beta
,legendre
, etcThese functions will be of principal interest to programmers in the engineering and scientific disciplines.
The following table shows all 23 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
orlong double
values respectively. For example:Containers
Tuple Types
* new
header file -tuple
* based on Boost Tuple library [http://www.boost.org/libs/tuple/doc/tuple_users_guide.html]
* vaguely an extension of the standardstd::pair
* fixed size collection of elements, which may be of different typesFixed Size Array
* new
header file -array
* lifted from Boost Array library [http://www.boost.org/doc/html/array.html]
* as opposed to dynamic array types such as the standardstd::vector
Hash Tables
* new
,<
header filesunordered map >
* new implementation, not derived from an existing library, not fully API compatible with existing libraries
* like allhash table s, often provide constant time lookup of elements but the worst case can be linear in the size of the containerRegular Expressions
* new
header file -regex
,regex_match
,regex_search
,regex_replace
, etc
* based on Boost RegEx library [http://www.boost.org/doc/libs/1_36_0/libs/regex/doc/html/index.html]
* pattern matching libraryC 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 as, , , etc. These changes help to bring C++ more in line with the C99 version of the C standard (not all parts of C99 are included in TR1). ee also
*
Boost library , a large collection of portable C++ libraries, several of which were included in TR1
*Standard Template Library , part of the current C++ Standard Library
*C++0x , the planned new standard for the C++ programming language
*Dinkumware , the only commercial vendor to fully implement TR1Fact|date=August 2008References
*cite paper | title = Draft Technical Report on C++ Library Extensions | url = http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf | date = 2005-06-24 | format =
PDF | last = ISO/IEC JTC1/SC22/WG21
*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-0External links
* [http://aristeia.com/EC3E/TR1_info_frames.html Scott Meyers' Effective C++: TR1 Information] - contains links to the TR1 proposal documents which provide background and rationale for the TR1 libraries.
Wikimedia Foundation. 2010.