カナダの
中央部から米国南西部へ! アルバカーキはニューメキシコ州にあります。

この都市で開催されたC ++標準化国際委員会の会議で、彼らはC ++ 20の非常に大きなイノベーションといくつかの小さなイノベーションを採用しました。
演算子<=>
宇宙船演算子がC ++ 20ドラフトに追加され、1回の操作で要素の比率を決定できます。 単純な場合、これは、宇宙船演算子を定義できることを意味し、クラスは<、>、<=、> =、==および!=のいずれかの方法で比較することを学びます。 例:
宇宙船オペレーターなし | 宇宙船オペレーターと |
---|
struct point3d {
int x;
int y;
int z;
};
using p_ref = const point3d&;
bool operator==(p_ref a, p_ref b) {
return a.x == b.x
&& a.y == b.y
&& a.z == b.z
;
}
bool operator< (p_ref a, p_ref b) {
return a.x < b.x
|| (a.x == b.x && a.y < b.y)
|| (a.x == b.x && a.y == b.y
&& a.z < b.z)
;
}
bool operator!=(p_ref a, p_ref b) {
return !(a == b);
}
bool operator<=(p_ref a, p_ref b) {
return !(b < a);
}
bool operator> (p_ref a, p_ref b) {
return b < a;
}
bool operator>=(p_ref a, p_ref b) {
return !(a < b);
}
| struct point3d {
int x;
int y;
int z;
auto operator<=>(const point3d&)
const = default;
};
|
:
class weak_equality;
class strong_equality;
class partial_ordering;
class weak_ordering;
class strong_ordering;
, , - :
#include <compare> // weak_ordering, is_neq
struct point3d {
int x;
int y;
int z;
std::weak_ordering operator<=>(const point3d& p) const {
using std::abs;
if (auto cmp = abs(z) <=> abs(p.z); std::is_neq(cmp)) return cmp;
if (auto cmp = abs(x) <=> abs(p.x); std::is_neq(cmp)) return cmp;
return abs(y) <=> abs(p.y);
}
};
. spaceship
*.
, :
lexicographical_compare_3way(InputIterator1 b1, InputIterator1 e1, InputIterator2 b2, InputIterator2 e2);
, , .
osyncstream
std::cout/std::cerr :
#include <iostream>
#include <thread>
#include <string_view>
void say_hello(std::string_view username) {
std::cerr << "Hello " << username;
}
void beware_of(std::string_view something) {
std::cerr << something << " is dangerous";
}
int main() {
std::thread t1([]{
say_hello("Rachel");
});
std::thread t2([]{
beware_of("darkness");
});
std::cerr << '\n';
t2.join();
t1.join();
/* Possible output:
Hello darkness
Rachel is dangerous
*/
}
, C++20 , :
#include <iostream>
#include <thread>
#include <string_view>
void say_hello(std::string_view username) {
std::osyncstream{std::cerr} << "Hello " << username;
}
void beware_of(std::string_view something) {
std::osyncstream(std::cerr) << something << " is dangerous";
}
int main() {
std::thread t1([]{
say_hello("Rachel");
});
std::thread t2([]{
beware_of("darkness");
});
std::cerr << '\n';
t2.join();
t1.join();
}
—
*.
, , :
- P0539R2 — integers, ( ) . , , . proposal.
- P0415R0* — constexpr std::complex. C++20 constexpr.
- P0202R2* — constexpr <algorithm>. C++20 , , std::swap. , proposal.
- P0275R2 — shared_library , . Evolution, , . Library Evolution .
- P0858R0 ( ) — . std::basic_string_view std::array constexpr . C++20.
, :
- P0457R1 — starts_with ends_with . C++20. !
- P0458R0 — contains(key) member [unordered_]map/set/multimap/multiset. LWG, , , C++20.
- range based for :
for (T thing = f(); auto& x : thing.items())
- :
using greater_t = decltype([](auto x, auto y) { return x > y; });
std::map<std::string, int, greater_t> map;
constexpr greater_t comparator{}; // OK
- std::is_pod std::is_pod_v deprecated.
- type trait std::remove_cvref.
- [[nodiscard]] async(), new, allocate(), empty() launder().
- std::memory_order* scoped enum.
- :
template <class T> struct atomic<shared_ptr<T>>;
template <class T> struct atomic<weak_ptr<T>>;
- std::atomic.
- .
Modules TS Networking TS.
C++20? C++17, 14 11? C++? :
stdcpp.ru. !
?
- .
27 21,
. —
. ,
C++ User Group .
* .