For faster navigation, this Iframe is preloading the Wikiwand page for C++ Technical Report 1.

C++ Technical Report 1

C++ > C++ Technical Report 1

C++ Technical Report 1 (TR1、Technical Report on C++ Library Extensions)は、ISO/IEC TR 19768:2007[1] の非公式名称で、標準C++ライブラリの拡張についての標準規格である。これには正規表現スマートポインタハッシュ表擬似乱数生成器などが含まれている。TR1の目標は「拡張された標準C++ライブラリの使用方法について慣習を確立してほしい」とのことである[2]

概要

[編集]

TR1は既に一部ないし全部を実装しているものもある。ちなみに、TR1のほとんどはBoostに含まれており、それが利用可能である。

TR1はC++のライブラリの拡張の全てではない。たとえばC++11ではスレッドに関するライブラリが含まれ、言語機能自体の拡張(move semanticsやvariadic templatesの追加など)などSTL全体に機能増強が行われた。

なお、TR1で追加されたライブラリは、現標準ライブラリと区別するため、名前空間 std::tr1 に入れられている。しかし、C++11では名前空間 std に入れられた。

TR1にとってC++11は必須ではないが、現行のC++上で全て実装可能というわけでもない。例えば、型のPOD性を検査する関数is_podの実装にあたって、現行のC++にはクラスがPODであることを判別する方法が無い。したがって、現在のC++処理系でのTR1実装は、コンパイラ独自の拡張機能を使用するか、あるいは擬似的な実現に留まる。この状況は、かつて一部コンパイラがテンプレートの部分特殊化に対応していなかった時代のSTLの擬似実装とよく似ている。

注意点としては、TR1はC++の仕様の一部ではないので、std::tr1 名前空間やTR1の機能に依存したコードは後々問題を起こす可能性がある。というのも、最近のドラフトであるn3225[2]では<type_traits>で定義される has_*is_* へ変更されている。また、std::tr1 は次期標準の仕様にも含まれないので注意されたい。

実装

[編集]

次のような実装が存在する。

内容

[編集]

TR1には次のものが含まれている。

一般ユーティリティ

[編集]

参照ラッパ

[編集]
  • Boost Smart Pointer libraryを基にしている [4]
  • <memory>ヘッダに追加。 - shared_ptr, weak_ptr, etc
  • より安全にメモリ管理を行うためのユーティリティ。参照カウントに基づくスマートポインタである。

<functional>ヘッダに4つのモジュールが追加。

function - 多態的関数ラッパ

[編集]
  • Boost.Functionを基にしている[5]

bind - 関数オブジェクトの束縛

[編集]
  • Boost Bind libraryから採用された[6]
  • 現標準のstd::bind1st及びstd::bind2ndをより一般化したもので、関数オブジェクトへ引数の束縛を行う。

result_of - 関数の戻り値の型

[編集]
  • Boostを基にしている。
  • 関数呼出式から、戻り値の型を決める機構。

mem_fn

[編集]
  • Boost Mem Fn libraryを基にしている[7]
  • 現標準のstd::mem_fun及びstd::mem_fun_refから機能向上したものである。
  • メンバ関数へのポインタを関数オブジェクトにする機構である。
  • 新しく<type_traits>ヘッダが追加。 - is_pod, has_virtual_destructor(C++11ではis_virtual_destructibleに変更), remove_extent, etc
  • Boost Type Traits libraryを基にしている[8]
  • データ型に関しての問い合わせを容易にすることによってメタプログラミングの支援をする。

数値計算

[編集]
  • 新しく<random>ヘッダが追加。 - variate_generator, mersenne_twister, poisson_distribution, etc
  • Boost Random Number Libraryを基にしている[9]

数学関数

[編集]
  • <cmath>/<math.h>ヘッダに追加。 - beta, legendre, etc
  • 各種数学関数。
  • 新しく<tuple>ヘッダが追加。 - tuple
  • Boost Tuple libraryを基にしている[10]
  • およそstd::pairの拡張である。
  • さまざまなデータ型を混在できる容量固定のデータ構造である。

容量固定配列

[編集]
  • 新しく<array>ヘッダが追加。 - array
  • Boost Array libraryから採用された[11]
  • 標準のstd::vectorのような動的配列とは全く逆の存在である。
  • 新しく<unordered_set>, <unordered_map>ヘッダが追加。
  • 既存のライブラリを基にしたものではなく、新たに作られたものである。
  • 要素の参照は、大抵の場合定数時間で済むが、最悪の場合には線形時間かかる。
  • 名前がhash_set(SGI版STLに含まれるライブラリ)などでないが、標準のset,mapはイテレータを用いて順序付けされた(ソートされた)要素アクセスが可能であるのに対し、unordered_set, unordered_mapでは不可能であることを示している。実装ではなくインターフェース(利用法)に由来した名前をつける発想である。

正規表現

[編集]
  • 新たに<regex>ヘッダが追加。 - regex, regex_match, regex_search, regex_replace, etc
  • Boost Regex libraryを基にしている[12]
  • 正規表現によるパターンマッチングを行うライブラリ。

C互換ライブラリ

[編集]

C++C言語と互換になるように設計されているものの、現在C++は厳密な上位互換ではない。TR1はその溝を埋めるため<complex>, <locale>, <cmath>その他のヘッダに拡張を行っている。これによってC99とある程度は近づいたものの、C99の全てがTR1に含まれているわけではない。

C++ Technical Report 2

[編集]

C++ Technical Report 2 も作られたが[7]、正式に出版されることはなかった。

脚注

[編集]
  1. ^ ISO/IEC TR 19768:2007
  2. ^ [1]
  3. ^ Visual C++ 2008 Feature Pack Release” (2008年4月22日). 2009年8月2日閲覧。
  4. ^ 標準 C++ ライブラリ TR1 拡張リファレンス”. 2009年8月29日閲覧。
  5. ^ The GNU C++ Library Documentation Chapter 1. Status”. 2009年8月29日閲覧。
  6. ^ Boost Libraries Chapter 21. Boost.TR1”. 2009年8月29日閲覧。
  7. ^ TR2 call for proposals

関連項目

[編集]
  • C++11 - TR1の内容が取り込まれたC++標準。
  • C++14
  • Boost - TR1の一部のライブラリの基となっている。
  • Standard Template Library - 現標準C++ライブラリの一部である。

参考文献

[編集]
  • Peter Becker: "The C++ Standard Library Extensions: A Tutorial and Reference", 2006, ISBN 0321412990. TR1にも言及している。

外部リンク

[編集]
{{bottomLinkPreText}} {{bottomLinkText}}
C++ Technical Report 1
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?