C ++ 17で採用されたもの、Bjarne Straustrupによる写真、C ++ 20の調査


3月上旬、アメリカのコナ市で、標準化C ++に関する国際ワーキンググループWG21の会議が終了し、 Yandexの従業員が参加しました
C ++ 17 "承認済み"!
完全に正確にするために、C ++ 17ドラフト文書を上位のISO本体に転送し、標準としてリリースするか、正しい書式設定およびその他の形式に戻すために送信するときが来たと判断しました。

いつものように、会議は丸一日かかり、それに加えて数字を扱うサブグループが追加されました。

ほとんどの時間はドラフトC ++ 17の洗練に専念していましたが、いくつかの小さくて興味深い革新がいまだにC ++ 17に組み込まれています。


20年待って...


std::ofstream(L"      .txt") << u8"!";


std::optional


std::optional :
template <class T>
bool operator < (const optional<T>&, const T&);
// ...

:

optional<const int> x = 42;
int y = 666;
x == y; //  
...

optional<string> s = "Hello";
s == "Hello"; //  


, :
template <class T, class U>
bool operator < (const optional<T>&, const U&);
// ...

, 's == «Hello»' .

Deduction guides


deduction guides, :

// !     .
std::tuple      a = {42, "Hello", 3.14};
std::array      b = {1, 2, 3, 4, 5, 6, 7, 8};
std::pair       c = {42, "Hello"};
std::function   d = [](int i) { std::cout << i; };
std::set        e = {1, 2, 3, 4, 5, 6, 7, 8};

// P.S.:     '='     :)


std::array
explicit deduction guides std::array.

WG21 C++, , , explicit deduction guides std::array. , … !


std::byte


- , - « »? C ++17 std::byte
unsigned char raw_buffer[buffer_size];
std::byte raw_buffer[buffer_size];
.

,


. :



, ++ . C++17, C++20. .

Numbers TS


, , , , . Numbers TS — . :

, .

operator<=>()


operator<=>(). , C++20 :
struct foo { /*     */ };

auto operator<=>(const foo&, const foo&) = default; //      foo c foo
auto operator<=>(const foo&, const char*) = default; //      foo c const char*      const char*  foo



, //«-», , constexpr constexpr , constexpr « », , . , 21 , ++ ++17 . — WG21 C++.


C++17 , !

C++20, C++17/C++14/C++11, C++, stdcpp.ru. !

! ++ , , .


Source: https://habr.com/ru/post/J323972/


All Articles