C++ Technical Report 1

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 include regular expressions, smart pointers, hash tables, and random number generators. 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 the header file - cref, ref, reference_wrapper
* enables passing references, rather than copies, into algorithms or function objects

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):void f( int &r ) { r++; }

template< class F, class P > void g( F f, P t ) { f(t); }

int main(){ int i = 0; g( f, i ); // 'g< void(int &r), int >' is instantiated cout << i << endl; // Output: 0

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

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 the Resource Acquisition Is Initialization (RAII) idiom

Function 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 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 to be treated as function objects

Metaprogramming 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 types

Numerical Facilities

Random Number Generation

* new header file - variate_generator, mersenne twister, poisson distribution, etc
* utilities for generating random numbers using various engines and probability 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, etc

These 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 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 [http://www.boost.org/libs/tuple/doc/tuple_users_guide.html]
* 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
* lifted from Boost Array library [http://www.boost.org/doc/html/array.html]
* as opposed to dynamic array types such as the standard std::vector

Hash Tables

* new , <unordered map> header files
* 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 [http://www.boost.org/doc/libs/1_36_0/libs/regex/doc/html/index.html]
* 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 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 2008

References

*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-0

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

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Technical report — A technical report (also: scientific report) is a document that describes the process, progress, or results of technical or scientific research, or the state of a technical or scientific research problem. Unlike other scientific literature, such… …   Wikipedia

  • C++ Technical Report 1 — (TR1) является общим названием для стандарта ISO / IEC TR 19768, библиотеки расширений C++  это документ с предложением дополнений в стандарт библиотеки С++. Дополнения включают регулярные выражения, умные указатели, хэш таблицы, и… …   Википедия

  • technical — technically, adv. technicalness, n. /tek ni keuhl/, adj. 1. belonging or pertaining to an art, science, or the like: technical skill. 2. peculiar to or characteristic of a particular art, science, profession, trade, etc.: technical details. 3.… …   Universalium

  • Technical communication — is the process of conveying usable information through writing or speech about a specific domain to an intended audience. Information is usable if the intended audience is able to perform an action or make a decision based on its contents… …   Wikipedia

  • Technical diving — Technical diver during a decompression stop. Technical diving (sometimes referred to as Tec diving) is a form of scuba diving that exceeds the scope of recreational diving (although the vast majority of technical divers dive for recreation and… …   Wikipedia

  • Technical debt — (also known as design debt or code debt) are synonymous, neologistic metaphors referring to the eventual consequences of poor software architecture and software development within a codebase. Common causes of technical debt include (a combination …   Wikipedia

  • Technical intelligence — In a pure military context, Technical Intelligence (TECHINT) is intelligence about weapons and equipment used by the armed forces of foreign nations (often referred to as foreign materiel).The related term, scientific and technical intelligence,… …   Wikipedia

  • Technical Service Council — The TECHNICAL SERVICE COUNCIL was set up to combat the brain drain of Canadian engineers to the United States, when over 20% of the graduating classes were emigrating. Ireland, India, New Zealand and even Switzerland have had similar problems.In… …   Wikipedia

  • Report — For other uses, see Report (disambiguation). Example of a front page of a report A report is a textual work (usually of writing, speech, television, or film) made with the specific intention of relaying information or recounting certain events in …   Wikipedia

  • Technical Education Center Osceola — Infobox School name = Technical Education Center Osceola established = 1994 type = Public secondary accreditation = [http://www.council.org/ Council on Occupational Education (COE)] [http://www.sacs.org/ Southern Association of Colleges and… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”