Technical Report 1
Encyclopedia
C++ Technical Report 1 is the common name for ISO/IEC TR 19768, C++ Library Extensions, which was a document proposing additions to the C++ standard library
C++ standard library
In C++, the C++ Standard Library is a collection of classes and functions, which are written in the core language and part of the C++ ISO Standard itself...

 for the C++03 language standard. The additions include regular expression
Regular expression
In computing, a regular expression provides a concise and flexible means for "matching" strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp"...

s, smart pointer
Smart pointer
In computer science, a smart pointer is an abstract data type that simulates a pointer while providing additional features, such as automatic garbage collection or bounds checking. These additional features are intended to reduce bugs caused by the misuse of pointers while retaining efficiency...

s, hash table
Hash table
In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys , to their associated values . Thus, a hash table implements an associative array...

s, and random number generators. TR1 is not a standard itself, but rather a draft document. However, most of its proposals became part of the current official standard, C++11. Before C++11 was standardized, vendors used 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 appear in the next standard; for example, the current standard, C++11, supports threading
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...

. There is also a second technical report, C++ Technical Report 2, planned for publishing after C++11 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1810.html.

The new components are in the std::tr1 namespace
Namespace (computer science)
A namespace is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols . An identifier defined in a namespace is associated only with that namespace. The same identifier can be independently defined in multiple namespaces...

 to distinguish them from the current standard library.

Reference wrapper

  • based on Boost.Ref http://www.boost.org/doc/html/ref.html
  • additions to the header file
    Header file
    Some programming languages use header files. These files allow programmers to separate certain elements of a program's source code into reusable files. Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers...

     - cref, ref, reference_wrapper
  • enables passing references, rather than copies, into algorithms or function objects


A wrapper
Adapter pattern
In computer programming, the adapter pattern is a design pattern that translates one interface for a class into a compatible interface...

 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):
  1. include
  2. include


void f( int &r ) { ++r; }

template< class Funct, class Arg >
void g( Funct f, Arg t )
{
f(t);
}

int main
{
int i = 0;

g( f, i ); // 'g< void(int &r), int >' is instantiated
std::cout << i << "\n"; // Output: 0

g( f, std::tr1::ref(i) ); // 'g< void(int &r), reference_wrapper >' is instanced
std::cout << i << "\n"; // Output: 1
}


Smart 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 the Resource Acquisition Is Initialization
    Resource Acquisition Is Initialization
    Resource Acquisition Is Initialization is a programming idiom used in several object-oriented languages like C++, D and Ada. The technique was invented by Bjarne Stroustrup to deal with resource deallocation in C++...

     (RAII) idiom

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 standard std::bind1st and std::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 expression

mem_fn

  • mem_fn
  • based on Boost Mem Fn library http://www.boost.org/libs/bind/mem_fn.html
  • enhancement to the standard std::mem_fun and std::mem_fun_ref
  • allows pointers to member functions
    Subroutine
    In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

     to be treated as function objects

Metaprogramming and type traits


Random number generation

  • new header file - variate_generator, mersenne twister, poisson distribution
    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 and/or space if these events occur with a known average rate and independently of the time since...

    , 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.

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.
Function name Function prototype Mathematical expression
Associated Laguerre polynomials double assoc_laguerre( unsigned n, unsigned m, double x ) ;
Associated Legendre polynomials
Associated Legendre polynomials
In mathematics, the associated Legendre polynomials are the canonical solutions of the general Legendre equation\,y -2xy' + \left\,y = 0,\,or equivalently...

double assoc_legendre( unsigned l, unsigned m, double x ) ;
Beta function double beta( double x, double y ) ;
Complete elliptic integral of the first kind double comp_ellint_1( double k ) ;
Complete elliptic integral of the second kind double comp_ellint_2( double k ) ;
Complete elliptic integral of the third kind double comp_ellint_3( double k, double nu ) ;
Confluent hypergeometric functions double conf_hyperg( double a, double c, double x ) ;
Regular modified cylindrical Bessel functions double cyl_bessel_i( double nu, double x ) ;
Cylindrical Bessel functions of the first kind double cyl_bessel_j( double nu, double x ) ;
Irregular modified cylindrical Bessel functions double cyl_bessel_k( double nu, double x ) ;
Cylindrical Neumann functions
Cylindrical Bessel functions of the second kind
double cyl_neumann( double nu, double x ) ;
Incomplete elliptic integral of the first kind double ellint_1( double k, double phi ) ;
Incomplete elliptic integral of the second kind double ellint_2( double k, double phi ) ;
Incomplete elliptic integral of the third kind double ellint_3( double k, double nu, double phi ) ;
Exponential integral
Exponential integral
In mathematics, the exponential integral is a special function defined on the complex plane given the symbol Ei.-Definitions:For real, nonzero values of x, the exponential integral Ei can be defined as...

double expint( double x ) ;
Hermite polynomials
Hermite polynomials
In mathematics, the Hermite polynomials are a classical orthogonal polynomial sequence that arise in probability, such as the Edgeworth series; in combinatorics, as an example of an Appell sequence, obeying the umbral calculus; in numerical analysis as Gaussian quadrature; and in physics, where...

double hermite( unsigned n, double x ) ;
Hypergeometric series
Hypergeometric series
In mathematics, a generalized hypergeometric series is a series in which the ratio of successive coefficients indexed by n is a rational function of n. The series, if convergent, defines a generalized hypergeometric function, which may then be defined over a wider domain of the argument by...

double hyperg( double a, double b, double c, double x ) ;
Laguerre polynomials
Laguerre polynomials
In mathematics, the Laguerre polynomials, named after Edmond Laguerre ,are the canonical solutions of Laguerre's equation:x\,y + \,y' + n\,y = 0\,which is a second-order linear differential equation....

double laguerre( unsigned n, double x ) ;
Legendre polynomials double legendre( unsigned l, double x ) ;
Riemann zeta function double riemann_zeta( double x ) ;
Spherical Bessel functions of the first kind double sph_bessel( unsigned n, double x ) ;
Spherical associated Legendre functions double sph_legendre( unsigned l, unsigned m, double theta ) ;
Spherical Neumann functions
Spherical Bessel functions of the second kind
double sph_neumann( unsigned n, double x ) ;

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 ) ;

Tuple types


Fixed size array


Hash tables

  • new , <unordered map
    Unordered map (C++)
    unordered_map is a class template representing a hash table in the C++ Technical Report 1 and the C++11 standard. It is similar to the hash_map class template of the original STL which was also included in several implementations of the C++ Standard Library unordered_map is a class template...

    >
    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
    Hash table
    In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys , to their associated values . Thus, a hash table implements an associative array...

    s, often provide constant time lookup of elements but the worst case can be linear in the size of the container

Regular expressions


C compatibility

C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 is designed to be compatible with the C programming language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

, 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).

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 programmers.http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1810.html.

Some of the proposals include:

See also

  • C++11, the most recent standard for the C++ programming language; the library improvements were based on TR1
  • C99
    C99
    C99 is a modern dialect of the C programming language. It extends the previous version with new linguistic and library features, and helps implementations make better use of available computer hardware and compiler technology.-History:...

    , the most recent standard for the C programming language
  • Boost library
    Boost library
    Boost is a set of free software libraries that extend the functionality of C++.-Overview:Most of the Boost libraries are licensed under the Boost Software License, designed to allow Boost to be used with both free and proprietary software projects...

    , a large collection of portable C++ libraries, several of which were included in TR1
  • Standard Template Library
    Standard Template Library
    The Standard Template Library is a C++ software library which later evolved into the C++ Standard Library. It provides four components called algorithms, containers, functors, and iterators. More specifically, the C++ Standard Library is based on the STL published by SGI. Both include some...

    , part of the current C++ Standard Library
  • Dinkumware
    Dinkumware
    Dinkumware is a software company specializing in core libraries for C/.The company has provided the standard library implementation that ships with Microsoft since 1996, and claims to be the leading supplier of and libraries to the embedded community.They also provide libraries for Java and...

    , the only commercial vendor to fully implement TR1

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK