首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-05-16 13:58:32

線路代号30的表示方法?anon類模闆參數推導,今天小編就來聊一聊關于線路代号30的表示方法?接下來我們就一起去研究一下吧!

線路代号30的表示方法(C17in)1

線路代号30的表示方法

anon

類模闆參數推導

std::pair p(2, 4.5); // std::pair<int, double> std::tuple t(4, 3, 2.5); // std::tuple<int, int, double>

inline variable

// In a.hpp inline SomeType singletonVar;

每個翻譯單元都要include a.hpp,最後隻會保留一個

細化Evaluation order

a[i ] = i; // 等号右邊的現在規定會先計算完成 /* a.b a->b a->*b a(b1, b2, b3) b @= a a[b] a << b a >> b 現在都會a, b, c, d順序計算 */

guaranteed copy elision

std::mutex a_mutex; std::lock_guard<std::mutex> get_lock { return std::lock_guard<std::mutex>(a_mutex); // lock_guard沒有複制、移動構造函數。17之前這句不合法(盡管事實上都能編譯過)。17之後auto lock = get_lock;就合法了 }

if statement with initilizer

if (auto it = m.find(10); it != m.end) // return *it

structured binding

std::map<int, int> m; auto [iter, ok] = m.insert({1, 2}); // insert返回pair<Iterator, bool>

string_view

std::string cppstr = "Foo"; std::string_view cppstr_v(&cppstr[0], cppstr.size); cppstr[0] = 'A'; std::cout << cppstr_v; // Aoo

嵌套namespace

namespace a::b { // ... }

if constexpr

template<typename ... Ts> void f(Ts ... args) { if constexpr(sizeof... (args) > 0) f1(args..); else f1(default_arg); }

Fold 表達式

template<typename ... Ts> constexpr int sum(Ts... args) { return ( 0 ... args ); // = ( (0 arg0) arg1 ) arg2 ... } static_assert(10 == sum(2, 3, 5)); // static_assert可以沒有信息了

模闆非類型參數auto

template<auto C> struct Size { static const size_t size = sizeof(C); }; static_assert(Size<3>::size == sizeof(3)); static_assert(Size<(void*)0>::size == sizeof(void*));

lambda改進

struct Foo { int val; void f { (*this) { val = 100; }; // 複制了整個對象進lambda } }; Foo obj {42}; obj.f; assert(obj.val == 42); auto getSize = (auto o) { return sizeof(o); } // 這是constexpr了 static_assert(getSize(obj) == sizeof(Foo));

void_t,更方便的SFINAE

template< class, class = std::void_t<> > struct has_type_member : std::false_type { }; template< class T > struct has_type_member<T, std::void_t<typename T::type>> : std::true_type { };

{variant/optional/any}

optional<const char*> get_foo { if (...) return some_msg; else return {}; } std::cout << get_foo.value_or("Not found!");

variant<int, float> v, w; v = 12; int i = get<int>(v); w = get<int>(v); w = get<0>(v); // 同上 w = v; // 同上 get<double>(v); // ill formed

<algorithm>改進

std::sort(std::execution::par, std::begin(v), std::end(v)); // 并行版 std::vector<int> v2{ 1, 2, 4, 5, 0 }; assert(12 == std::reduce(std::execution::par, std::begin(v2), std::end(v2))); // 亂序版accumulate

filesystem

std::filesystem::copy("/etc/resolv.conf", "./resolv.conf", std::filesystem::copy_options::overwrite_existing); for (auto it = std::filesystem::recursive_directory_iterator("/usr/bin"); it != std::filesystem::recursive_directory_iterator; it) { std::cout << it->path << std::endl; }

Aligned dynamic allocation

namespace std { enum class align_val_t: size_t; }; void *operator new(std::size_t, std::align_val_t);// new overload 分配一段對齊的内存

在不同容器間移動結點

map<int, string> src {{1,"one"}, {2,"two"}, {3,"buckle my shoe"}}; map<int, string> dst {{3,"three"}}; dst.insert( src.extract( src.find(1) ) ); dst.insert( src.extract(2) );

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
推荐阅读
第一家國家級航海博物館在哪裡
第一家國家級航海博物館在哪裡
1、第一家國家級航海博物館在上海。2、位于上海的中國航海博物館,是經國務院批準設立的中國第一家國家級...
2026-05-16
高鐵票如何選2人座位
高鐵票如何選2人座位
1、在手機上面下載一個智行12306購票軟件,然後登錄。2、選擇所乘坐的高鐵起點和終點,然後點擊“查詢”。3、查詢一班想乘坐的高鐵,然後點擊“預定”。4、在列出的預訂頁面中,點擊選擇坐席。5、這時會顯示D/F座位,這就是2個人在一起的座位,然後點擊“确定”即可。高速鐵路,簡稱高鐵,是指設計标準等級高、可供列車安全高速行駛的鐵路
2026-05-16
哪些人會被上門催收
哪些人會被上門催收
1、逾期時間長。如果你逾期時間短,一般來說貸款機構會安排人進行猛烈催收,因為前面三個月回款的可能性更大,越到後面越不可能收回了,而且中小貸款機構不可能長時間的盯着一個人,逾期客戶越來越多,會把精力放在剛逾期的人身上。2、逾期金額大。逾期一千元和逾期十萬元,區别非常大,因為上門催收不僅需要人力、物力、...
2026-05-16
貝的由來
貝的由來
貝,早期甲骨文像水生甲殼動物的外形。造字本義:有石灰質硬殼的水生軟體動物。這種軟體水生動物的外殼因其美觀、經久、難得,被古人視為珍奇,後發展為原始貨币。晚期甲骨文突出了水生動物的兩根觸須。金文承續甲骨文字形。篆文承續晚期甲骨文字形。楷書依據草書字形,省去正體楷書字形中保存的甲殼上的兩道花紋。貝:貝,漢語漢字,讀作bèi,最早見于甲骨文,其本義是牡蛎、蛤或其它軟體動物中腹足類和瓣鰓類的
2026-05-16
農保外地就醫如何報銷
農保外地就醫如何報銷
1、帶患者身份證、兩張一寸彩色照片、新農合醫療證到縣合管辦辦理轉診備案手續。2、攜帶患者身份證、新農合醫療證和轉診備案手續到轉診醫院就醫,辦理新農合住院手續。3、出院後,憑患者本人身份證或戶口本)、新農合醫療證、病曆複印件、住院結算單有的是發票形式的)、住院費用清單、轉診備案手續到合管辦報銷。
2026-05-16
Copyright 2023-2026 - www.tftnews.com All Rights Reserved