首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-06-14 19:15:14

線路代号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
推荐阅读
淘寶定金付尾款後能退嗎
淘寶定金付尾款後能退嗎
在淘寶給商品付完尾款之後進行退貨一般都可以将定金一起退回,不同淘寶店鋪的規定略有不同,我們可以在退款之後詢問該店客服工作人員。若我們在購買商品時沒有及時支付尾款的話,不僅不能退回定金,還将無法獲得原本定好的商品。淘寶付尾款後可以退定金嗎 大多數情況下支付完尾款之後選擇退款、退貨是可以将定金一起退回來...
2026-06-14
雞油枞是什麼東西
雞油枞是什麼東西
雞油枞是雲南的一種特色食品,主要以雞枞為原料,再加上植物油、香辛料合練而成,比起新鮮的食材來說,它更貯藏,制作好之後放到陰涼的地方保存即可。雞油枞在吃的時候主要是作為酒佐飯的菜品,其口感具備甜、香、麻辣的特點,因此也能作為調料。什麼是雞油枞 雞油枞的主要材料是雞枞,它是雲南一種非常受歡迎的菌類,因其...
2026-06-14
空調不吹熱風怎麼回事
空調不吹熱風怎麼回事
1、空調防冷風系統:空調在剛開啟前10分鐘之内是不會馬上吹風的。2、因為空調有防冷風功能,剛開啟空調...
2026-06-14
鋼材公司名字簡單大氣460個 鋼材公司名稱大全簡單大氣參考起名
鋼材公司名字簡單大氣460個 鋼材公司名稱大全簡單大氣參考起名
鋼材公司名字簡單大氣460個1.振網鋼材公司2.坤聯鋼材公司3.威貝鋼材公司4.賽華鋼材公司5.寶文鋼材公司6.達雷鋼材公司7.中聯鋼材公司8.進一鋼材公司9.國潤鋼材公司10.彙同鋼材公司11.濤盈鋼材公司12.明珠鋼材公司13.運蘇鋼材公司14.大宏鋼材公司15.華冶鋼材公司16.頻洋鋼材公司1...
2026-06-14
五行屬火的字男孩用
五行屬火的字男孩用
1、晨——運用(日)字旁查找适合男孩用的五行屬火的字,與姓氏搭配意為:朝氣蓬勃、積極樂觀、陽光開朗的...
2026-06-14
Copyright 2023-2026 - www.tftnews.com All Rights Reserved