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

線路代号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
推荐阅读
世界将成為你的顔色純音樂(而我們在輸出音樂)
世界将成為你的顔色純音樂(而我們在輸出音樂)
     2016年7月30日,吳蠻在國家大劇院音樂廳與華陰老腔合作,舉行音樂會。吳蠻覺得華陰老腔“非常真實”,“不像我們這些所謂音樂廳裡頭的音樂家,都磨得光光的。”(受訪者供圖/圖)   (本文首發于2017年4月20日《南方周末》,原标題為《“世界踉踉跄跄,而我們在輸出音樂” 琵琶演奏家吳蠻的去與歸》)   從美國聖地亞哥飛往上海的航班上,吳蠻将琵琶小心...
2026-06-19
我能扶你起來嗎原版(扶我起來我還能繼續看)
我能扶你起來嗎原版(扶我起來我還能繼續看)
                             ,
2026-06-19
魔獸世界有哪些隐藏坐騎掉落(魔獸世界解密坐騎主腦)
魔獸世界有哪些隐藏坐騎掉落(魔獸世界解密坐騎主腦)
  随着8.1的上線,全新的解密坐騎主腦出現在了玩家的眼前,國内外玩家都在艾澤拉斯找着有關解密的蛛絲馬迹。      昨日有一位國外的玩家就在沙塔斯的貧民窟發現了一些線索。在NPC處購買"正牌尋寶護符"後,該NPC背後桌子上的物品便會發起光芒,分别是藍色的信封、黃色的金字塔、綠色的羽毛、紅色的魚。這每一種顔色背後代表一條任務線,同時完成每一條任務線後,都會獲...
2026-06-19
社交媒體發展前景(社交媒體的發展曆程和發展趨勢)
社交媒體發展前景(社交媒體的發展曆程和發展趨勢)
  美國諷刺小說家馬克·吐溫在《競選州長》中,候選人“馬克·吐溫先生”在短短幾天内,被幾份報紙貼上了不同的罪名,有“酒瘋子”“盜屍犯”“小偷”“訛詐專家”“舞弊分子”。郁悶之餘,“馬克·吐溫先生”隻好選擇主動請辭。雖然馬克·吐溫的本意是吐槽當時的報紙毫無節操,肆意傳播流言,以吸引讀者眼球。但是我們也可以看到報紙作為一種社交媒體,在人們生活中的影響力不容小觑。...
2026-06-19
顔人中靠哪首歌火的(顔人中是怎麼火起來的)
顔人中靠哪首歌火的(顔人中是怎麼火起來的)
  6月17日,是顔人中25歲的生日。   去年的此刻,知道這個名字的人還不多。   而今年的此刻,從翻唱的《有可能的夜晚》《孤單心事》《膽小鬼》,到原唱的《晚安》《祝你愛我到天荒地老》……他的聲音似乎一夜之間跳進了千萬人的耳朵。   其實,現在還很少有人知道,從他第一次登上夢想中的音樂舞台,到今天,已經整整11年。   顔人中,你終于火了!   (此處插入...
2026-06-19
Copyright 2023-2026 - www.tftnews.com All Rights Reserved