首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-07-07 03:10:50

線路代号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、腸衣洗去表面的鹽,浸泡在清水裡至少30分鐘,讓腸衣充分泡開。2、豬肉用熱水洗淨,去皮切大塊,絞肉機把肉塊絞成大肉條。3、在肉條裡放入鹽、白糖、白酒、花椒粉,攪拌均勻。4、腸衣泡好以後在一頭打個結,把腸衣全部套在廚師機的漏鬥上。5、把肉全部灌入腸衣内,最後留一段5厘米左右的空白出來,末端打結。6、...
2026-07-07
買手機怎麼辦理分期付款
買手機怎麼辦理分期付款
第一、一般我們可以選擇在網上購買手機分期付款因為比較方便,像淘寶、京東等都可以使用,那麼今天小編就來教大家使用京東分期付款吧!一般高校都會有京東派,我們直接去京東派那裡要求工作人員幫我們辦理京東白條,當然也可以自己網上辦理,不過額度會小一些。第二、開通白條之後,我們就可以在京東上面找到自己喜歡的手機...
2026-07-07
盤點微信代購三大亂象
盤點微信代購三大亂象
第一、代購真假混亂,朋友也不靠譜由于很多國外東西國内購買渠道少,而且價格比較貴,很多人會托在國外的朋友幫忙購買,還有很多在國外的人用代購為副業,在朋友圈裡進行代購。一位愛美的劉小姐看到朋友圈有人在代購,于是托他購買了一些化妝品,拿到貨後與專櫃比較,發現有一部分是假的。之後她向那位朋友說了之後,堅持說...
2026-07-07
怎麼開一家飾品店
怎麼開一家飾品店
1、選品牌:在飾品行業,加盟一個成熟健康的品牌,會讓創業者在事業的道路上事半功倍。在這個過程中,不但可以學習到成熟的管理經驗和經營技巧,還能利用企業的品牌優勢和正向影響力開拓市場,進而讓自己的店鋪迅速穩定,快速成長。2、選地址:飾品店要的人氣和現金流,也就說做飾品必須要有人氣和财氣,人氣就是我們所說...
2026-07-07
烏魯木齊是哪個省
烏魯木齊是哪個省
新疆。烏魯木齊,通稱烏市,舊稱迪化,是新疆維吾爾自治區首府,國務院批複确定的中國西北地區重要的中心城市和面向中亞西亞的國際商貿中心。烏魯木齊地處中國西北地區、新疆中部、亞歐大陸中心、天山山脈中段北麓、準噶爾盆地南緣,毗鄰中亞各國,是新疆的政治、經濟、文化、科教和交通中心。西漢初年,漢朝即置戊己校尉在...
2026-07-07
Copyright 2023-2026 - www.tftnews.com All Rights Reserved