首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-06-17 22:44:41

線路代号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-17
現澆水磨石地面有哪些特點
現澆水磨石地面有哪些特點
1、水磨石地面處理後的亮度可達70以上,防塵、防滑可以達到大理石品質。2、水磨石地面硬度高,耐磨性能好,耐老化,耐腐蝕,無異味,無污染。3、水磨石地闆可以随意拼花,顔色可以自由定制,不怕重物壓制,不開裂,不變形。4、水磨石地闆的分格條之間沒有縫隙,連接密實,整體美觀性好,不容易起塵、潔淨度高。5、重...
2026-06-17
買花瓶應該注意什麼
買花瓶應該注意什麼
1、選擇陶瓷餐具時,不要使用釉色裝飾,特别是陶瓷餐具的内壁不應塗漆。它可以用釉下或釉料裝飾,如藍色和白色是人們喜歡用釉下彩裝飾的一種陶瓷。2、購買陶瓷餐具,先用4醋水浸泡煮沸,即可去除大部分有毒物質,大大降低了陶瓷餐具對人體的潛在危害。3、不要使用陶瓷餐具長期儲存酸性食品和飲料,如果汁,葡萄酒和咖啡...
2026-06-17
為朋友擔保要注意些什麼
為朋友擔保要注意些什麼
1、首先要了解這個要借款人的信譽。我們知道一個人在社會上的地位無非就是名與利。要人與人相處的好,在于一個誠字。而誠則是信譽的表現,因此我們給人做擔保的時候,一定要了解那個人的誠信與信譽。2、然後了解一下他的還款能力。如果我們當了朋友的擔保人,那麼就要注意他的經濟能力。有的人或許有實業,但是現金流斷了...
2026-06-17
如何在50分鐘内煮一鍋軟糯粘稠的八寶粥
如何在50分鐘内煮一鍋軟糯粘稠的八寶粥
第一、先把食材準備好,食無定式,我一般把家裡面現存的米類、堅果類、豆類的食材都放到一起做八寶粥,讓營養和口感更全面。如果想要八寶粥軟糯粘稠,建議大家一定要放一些糯米。第二、把備好的食材一起用清水迅速淘洗4遍,以防止髒水回滲,然後用幹淨的清水将食材浸泡1小時。第三、然後将食材和浸泡的水都放入電壓力鍋中...
2026-06-17
Copyright 2023-2026 - www.tftnews.com All Rights Reserved