首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2025-11-18 00:00:38

線路代号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-11-18
公務人員必須生二胎嗎
公務人員必須生二胎嗎
引言昨天帶着娃和小區一位鄰居媽媽聊天,聽說我是公務員,她立馬就說,那你還不趕緊生二胎啊,單位這麼好,不生可惜了。她這番話讓我想起了前陣子看到的一則新聞,“某85後為生二胎考公務員”。在我的鄰居和新聞中的女士看來,當上公務員,就意味着可以高枕...
2025-11-18
續航超300公裡的電動皮卡
續航超300公裡的電動皮卡
【卡車之家原創】江鈴域虎自上市以來,因其良好的性能先後被部隊、基建、電力、行政執法等部門所采購,高質量以及強穩定性受到了用戶的肯定。随着各地皮卡政策的放開以及國家對新能源車的支持,純電動皮卡開始走上舞台,而聚光燈下最耀眼的莫過于江鈴的域虎E...
2025-11-18
檀健次景甜rap
檀健次景甜rap
《追光吧哥哥》來的21個人,小編看了名單以後滿頭問号,這都是誰?誰??誰???來的都是什麼人啊,這個節目在小編眼中就是對标浪姐的,浪姐來的這些姐姐們,要麼都是曾經的頂流,比如黃聖依伊能靜甯靜,要麼就是有知名度有作品在身。而這些哥哥們,真的是...
2025-11-18
嫌疑人x的獻身感言
嫌疑人x的獻身感言
日本推理小說作家東野圭吾,對于喜愛偵探小說的書迷來說,可謂無人不曉。雖然,東野圭吾的作品深受大家的喜愛,但是,在文學獎項上,他并未得到偏愛。在1999年-2005年間,東野圭吾多部作品與日本文學獎-直木獎,擦身而過。後來,改變發生在2006...
2025-11-18
Copyright 2023-2025 - www.tftnews.com All Rights Reserved