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

線路代号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-04-18
餅幹防潮法 實用生活妙招
餅幹防潮法 實用生活妙招
餅幹防潮法實用生活妙招實用生活妙招餅幹的防潮法将餅乾裝罐時,同時放進一塊方糖。由於方糖會吸收罐中的濕氣,所以就能保持餅乾的香脆可口的狀态了。預防煮面食湯溢出來的方法水煮的時候,再湯裡加上一遲奶油或一點點沙拉油。同時要保持湯的沸騰,不可向煮其他面類時一般加冷水。如何去除指頭上的煙垢最有效的方法适用檸檬...
2026-04-18
家居除臭技巧
家居除臭技巧
臭味來源:玄關、鞋櫃除臭幫手:絲襪、報紙、咖啡或茶葉渣不少家庭把鞋櫃擺在玄關,玄關因此就很容易飄出臭味。想要解決這個問題,首先把鞋子統統搬出來,徹底清理幹淨,每雙鞋子先用幹布擦拭,接着鞋櫃内鋪上舊報紙數張。然後,在舊絲襪裡塞上曬幹的茶葉渣或咖啡渣,做成除臭包。一些塞入鞋内,一些擺在鞋櫃角落,對于消除...
2026-04-18
炭雕的搭配知識與保養方法
炭雕的搭配知識與保養方法
炭雕的搭配知識與保養方法炭雕的搭配知識1、可以持續吸附空氣中各種有毒氣體(一氧化氮、二氧化氮、甲醛、苯及其同系物、氨、氡、二氧化硫等)、煙霧、異味等,能有效淨化空氣,消除空氣污染,維護人體健康。2、能有效遏制黴菌及微生物繁衍,抑菌抑螨,調濕防黴。3、能阻隔電磁波,有效防止家用電器如電視、電腦、移動電...
2026-04-18
鼻子聞到臭味應該怎麼辦
鼻子聞到臭味應該怎麼辦
人類是一種特别敏感的東西它可以聞到很多東西,都不能嗅出的味道,那麼我們有的時候會不會鼻子發脹或者不舒服呢,有的人會因為鼻子而産生過敏性鼻炎也有的會感冒發燒的時候會鼻子堵塞,那麼,我們有沒有覺得有的時候鼻子聞到臭味的感覺呢,那麼鼻子聞到臭味兒應該怎麼辦呢?它是一種好的現象還是疾病呢,那我們來分析一下。...
2026-04-18
Copyright 2023-2026 - www.tftnews.com All Rights Reserved