首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2025-12-08 03:18:54

線路代号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
推荐阅读
清爽的卧室空間收納方案
清爽的卧室空間收納方案
清爽的卧室空間收納方案清爽的卧室空間收納方案白色的床搭配上天藍色的背景牆以及床單,首先在視覺上就給人一種特别優雅、清新的感覺。在你注意不到的地方還設計了抽屜樣式的收納,孩子的玩具、零碎的衣物之類的都可以放進去。綠色的地中海風格帶來明亮之感,但是收納是整個卧室的亮處,不僅床頭有兩個小收納櫃,同樣的整個...
2025-12-08
衣服混洗會導緻一件事
衣服混洗會導緻一件事
現在基每一個家庭裡面都是會有洗衣機的,所以大部分的人不再會用手洗衣服的,基本上都是把所有的衣服往洗衣機裡面一扔,然後就開始自動洗滌了,那您知道衣服混洗會人體交叉感染嗎?您知道服裝洗滌應按類分開的原因是什麼嗎?今天就為您介紹一下有關洗衣服的注意事項的知識,感興趣的朋友們趕快來看看啊。衣服混洗會人體交叉...
2025-12-08
眼鏡防霧的竅門
眼鏡防霧的竅門
眼鏡防霧的竅門:冬天從室外到室内,戴眼鏡的人總是會看不清東西,原因就是眼鏡上蒙了一層水汽,現在教你一個防止眼鏡起霧的竅門。步驟:1、将肥皂頭兒泡在溫水裡,做成肥皂水。2、将肥皂水均勻地塗抹在眼鏡片上。3、用眼鏡布輕輕擦幹淨即可。原理:因為肥皂含有油脂成分,将肥皂水塗抹在鏡片上,鏡片就不容易沾上水汽。...
2025-12-08
冰島古樹茶多少錢一斤?
冰島古樹茶多少錢一斤?
01不同類型的冰島古樹茶的價格會有很大的差異,有的時候甚至會相差好幾倍,最貴的要算500年的古樹茶,隻有這樣的古樹茶才能值萬元每公斤。100年以上的古樹茶葉可以達到8000元/公斤,而當地台地茶也已經超過2000元/公斤。冰島古樹茶多少錢一斤會根據不同的産地不同的類型來定義,2021年基本都在幾千塊...
2025-12-08
實木地闆養護法則 讓地闆在春季也容光煥發
實木地闆養護法則 讓地闆在春季也容光煥發
春季氣溫走高,室内溫度與濕度的變化随時都可能引發地闆、家具幹縮、開裂的現象。一些實木地闆養護法則能讓地闆在春季也容光煥發。下面就跟随作文庫知識百科了解一下吧!實木地闆的保養三法則一:地闆打蠟次數不宜頻繁春季天氣幹燥,尤其是目前室内仍有暖氣,輕易導緻居室内空氣更加幹燥,為了讓地闆“皮膚&r...
2025-12-08
Copyright 2023-2025 - www.tftnews.com All Rights Reserved