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

線路代号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
推荐阅读
買回來的絲襪怎麼處理會比較耐穿
買回來的絲襪怎麼處理會比較耐穿
新絲襪不要直接穿,先不拆封放進冰箱冷凍24小時以上,零下的溫度可以提高尼龍材質的柔韌性和耐磨性,減少絲襪勾絲還有脫線的幾率,然後在常溫狀态下晾幹即可。用溫水手洗可以增加絲襪的纖維韌性,是最佳洗滌方式。
2026-06-19
白花枝子花介紹
白花枝子花介紹
1、白花枝子花(學名:DracocephalumheterophyllumBenth.)是唇形科、青...
2026-06-19
為什麼我的平闆電腦老是停止運行
為什麼我的平闆電腦老是停止運行
1、平闆電腦開機就顯示啟動器已停止運行是平闆的系統故障,需要重裝系統才可以解決。2、首先重啟電腦。3...
2026-06-19
鐵鍋每次用完怎麼保養
鐵鍋每次用完怎麼保養
鐵鍋的保養方法1、鐵鍋在用的時間比較長了之後,外部都會有一層燒焦物,這個燒焦物會影響鐵鍋的加熱速度及視覺感視,可以将鐵鍋浸泡在溫水中,然後拿出來在上面抹上蘇打粉,這樣燒焦物就會軟化,再使用鋼絲球刷幹淨即可去除。2、鐵鍋炒完菜之後,建議不要清洗的太幹淨,這樣鐵鍋中的油可以防止鐵鍋生鏽。3、鐵鍋如果生鏽的話,可以加熱鐵鍋,用塗抹過醋的布擦拭生的地方,可以去除鐵鏽。4、鐵鍋剛買回家不要馬上使用,建議用肥
2026-06-19
鋁箔紙放烤箱用哪一面
鋁箔紙放烤箱用哪一面
錫箔紙亮面為正面,烤箱使用時,将錫箔紙亮面朝上。鋁箔紙的用途十分廣泛,如航空食品包裝,普通肉食包裝,煙卷包裝等。根據其應用特點的不同,可分為20多個品種。國家由于經濟發展水平的差異,鋁箔消費結構也存在很大差距。在歐美發達國家,用于包裝的鋁箔産品占總需求量的70%。在中國市場鋁箔主要是作為工業制造原輔材料,包裝鋁箔隻占國内需求總量的30%。雖然鋁箔包裝發展較晚,但市場增長迅速,前景引人關注。
2026-06-19
Copyright 2023-2026 - www.tftnews.com All Rights Reserved