首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-07-10 14:52:06

線路代号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
推荐阅读
二到四字網名幹淨480個 4個字内的昵稱大全
二到四字網名幹淨480個 4個字内的昵稱大全
二到四字網名幹淨480個1.小梨渦2.江厭離3.久夏青4.心不上鎖5.彼岸花6.蝴蝶夢7.獨步顔♪8.竹香子9.薄情涼性10.燕追星11.清風送别12.珂珂欣13.風啟觞14.勵志師15.月如鈎16.舊人序17.憐容18.爺們↘春哥19.清歡20.嘎嘣脆21.随夢22.蘇北陌23.陌筱苒24.舊人殇...
2026-07-10
山海經十大水屬性神獸 山海經神獸大全排名水屬性有哪些
山海經十大水屬性神獸 山海經神獸大全排名水屬性有哪些
中華文化曆史悠久,而山海經是中國怪古書籍,記載了一些極具神秘感奇異怪獸,想必大家也經常在網上會刷到一些山海經奇異怪獸的仿妝,對于山海經也有一些了解,但具體的了解也不是很多,下面小編就整理了一些山海經屬水的神獸,大家可以看看山海經裡水系神獸有哪些。1、應龍應龍為黃帝神龍,性别女,在《山海經·大荒東經》...
2026-07-10
徹底放棄一個人的昵稱400個 對某人失望心寒的昵稱
徹底放棄一個人的昵稱400個 對某人失望心寒的昵稱
徹底放棄一個人的昵稱400個1.墨染傾城色2.過期關系3.殘月封塵4.釋Hua1╮5.久居孤島o○6.卑微的承諾7.夢醒傷人心8.熱淚欲零9.跨越的溝壑10.江畔秋時月11.延續頹廢12.為你飲酒13.彼岸花開奈何橋14.今朝有酒今朝醉15.半憂郁少年16.極度悲傷17.誰還記得誰18.情何以堪19...
2026-07-10
最佳賞月時間
最佳賞月時間
1、2020中秋節時月亮升起的時間是在日落時,農曆十五,所以差不多是太陽下去之後月亮跟着就升起了,可...
2026-07-10
夏天怎麼存放面粉
夏天怎麼存放面粉
1、通風良好。必須使空氣流通,保持存放面粉的空間裡空氣的新鮮。2、濕度适宜。面粉會按環境的溫度及濕度...
2026-07-10
Copyright 2023-2026 - www.tftnews.com All Rights Reserved