首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-06-03 23:30:01

線路代号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
推荐阅读
怎樣洗滌拉絨衣物?拉絨衣物的洗滌方法
怎樣洗滌拉絨衣物?拉絨衣物的洗滌方法
拉絨織物有拉絨毛衣、圍巾、方巾、脖套、絨帽等,質地以腈綸産品居多,純毛次之。腈綸有靜電吸塵的特性,絨毛容易積塵垢。如洗滌不當,拉絨衣服容易變形,收縮闆結,失去彈性,更多的是使絨毛倒伏,影響柔軟蓬松。拉絨織物的洗滌方法是:把中性洗衣粉或肥皂片,用熱水沖開攪勻,用涼水對至30度左右。先用清水把衣物浸透,...
2026-06-03
打豆漿剩下黃豆渣的魔法變身
打豆漿剩下黃豆渣的魔法變身
随着養生風氣盛行,越來越多人喜愛在家中自制豆漿飲用。但熬煮後剩下的豆漿渣往往不知如何處理,直接食用沒有滋味,丢掉又覺得浪費!專家表示,不妨将黃豆渣回收再利用,加入日常菜肴中一同烹調食用,不僅有助增加飽足感,适度食用更有幫助減肥、通便的效果。打豆漿剩下黃豆渣的魔法變身黃豆渣高膳纖!增飽足、促排便日本知...
2026-06-03
實木地闆養護法則 讓地闆在春季也容光煥發
實木地闆養護法則 讓地闆在春季也容光煥發
春季氣溫走高,室内溫度與濕度的變化随時都可能引發地闆、家具幹縮、開裂的現象。一些實木地闆養護法則能讓地闆在春季也容光煥發。下面就跟随作文庫知識百科了解一下吧!實木地闆的保養三法則一:地闆打蠟次數不宜頻繁春季天氣幹燥,尤其是目前室内仍有暖氣,輕易導緻居室内空氣更加幹燥,為了讓地闆“皮膚&r...
2026-06-03
客廳挂什麼畫好?客廳挂畫給予舒适的家一種風格
客廳挂什麼畫好?客廳挂畫給予舒适的家一種風格
在家裝過程中很多人都會遇到這樣的情形:“房子裝修好了,但是感覺牆壁有點空”大片的留白,的确讓人不知所措。其實很簡單,一幅合适的裝飾畫就能很好的化解尴尬。那麼客廳挂什麼畫好呢?客廳是一個家庭對外開放的窗口,是戶主與密友談天說地的“仙人島”,它能體現主人的...
2026-06-03
夏天釣魚技巧
夏天釣魚技巧
可以說釣魚是一項休閑的運動吧,很多的朋友們都比較喜歡釣魚,但是釣魚也是很多的技巧跟方法的,尤其是在炎熱的夏天,朋友們一定要掌握釣魚的技巧,才能夠享受其中的樂趣,那麼夏天釣魚技巧都有哪些呢?喜歡釣魚的朋友們您不妨一起來看看文章的相關介紹吧,相信肯定會給您帶來幫助的。夏天釣魚技巧有哪些呢?因為夏天比較炎...
2026-06-03
Copyright 2023-2026 - www.tftnews.com All Rights Reserved