2017-11-13

今回C++ドラフトに入った機能

Trip report: Fall ISO C++ standards meeting (Albuquerque) | Sutter’s Mill

Herb Sutterが今回の標準化委員会の会議でドラフト入りした機能についていち早く速報を出している。具体的な文書などはリンク先で確認してもらうとして、概要だけ説明する。

range-based forに初期化子が書けるようになった。

for ( auto result = f() ; auto && value : result ) ;

<bit>にbit_castingが追加された。

short from = 42 ;
auto to = bit_cast<std::uint16_t>(from) ;

operator <=>が追加された。

operator <=>は2つのオペランドの大小比較と等号比較を一度にできる演算子だ。この演算子を定義しておけば、残りの比較演算子はコンパイラーが自動的に生成してくれる。型システムによってstrong order, weak order, partial orderのいずれに対応しているかも切り替えられる。

atomic<shared_ptr<T>>が追加された。shared_ptrをアトミックに操作できる。

remove_cvref traitsが追加された。CV修飾子とリファレンスを消したいが、配列から要素型、関数から関数へのポインター型への変換は行いたくない場合に、decayの代わりに使える。

[[nodiscard]]が一部の標準ライブラリで使われることになった。

同期バッファー付きのostreamラッパーライブラリ、osyncstreamが追加。

// 複数のスレッドから同時に実行されうる関数
void f()
{
    std::osyncstream out( std::cout ) ;
    out << "hello, world!\n" ; 
}

スレッドセーフなostreamラッパーとして使うことができる。

<alogorithm>と<utility>の一部をconstexpr対応。

<comlex>をconstexpr対応。

atomic<floating_point_type>

stringとstring_viewにstart_with/end_withの追加。

また、現在策定中のconstexpr対応のnew, vector, stringは、後数回の会議でドラフト入りできる見込みだというぐらい本格的に議論されているようだ。本気で入れる様子が伺える。

ドワンゴ広告

ドワンゴは本物のC++プログラマーを募集しています。

採用情報|株式会社ドワンゴ

CC BY-ND 4.0: Creative Commons — Attribution-NoDerivatives 4.0 International — CC BY-ND 4.0

1 comment:

opbest said...


Fantastic goods from you, man. I have understand your stuff previous to
and you’re just extremely excellent. I really like what
you have acquired here, certainly like what you are saying and the
way in which you say it. You make it enjoyable and you still take care
of to keep it wise. I cant wait to read much more from you.

This is really a terrific website.

Also visit my blog === 대구오피

(freaky)