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

線路代号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
推荐阅读
比較好的免洗面膜
比較好的免洗面膜
極奢免洗面膜好用到哭,居人沒推???瘋狂為它打call!極奢作為北京藥仙科技旗下經典系列體驗後就再也沒停下來,入入入10盒分給閨蜜x真的很好用啊!!!效果驚豔爆了!!!!敏感肌也能hold住我這大幹皮敏感,真是操碎了心首先說面膜的膜布剪裁很...
2026-07-22
不鏽鋼卡壓水管管件
不鏽鋼卡壓水管管件
“卡樂福不鏽鋼水管”是佛山不鏽鋼水管品牌廠家,專業生産不鏽鋼水管、水管管件、衛生級管件等。在飲用水方面堅持做“飲用水健康系統集成商”的戰略定位,引領社會創造水健康舒适生活。卡樂福不鏽鋼水管公司建立以來,接手的項目工程繁多,觸及的工程涵蓋了:...
2026-07-22
送白玫瑰的含義
送白玫瑰的含義
送白玫瑰的含義?白玫瑰看起來十分的純白,花語是天真、純潔,一般送白玫瑰則代表着純潔的愛,我來為大家講解一下關于送白玫瑰的含義?跟着小編一起來看一看吧!送白玫瑰的含義白玫瑰看起來十分的純白,花語是天真、純潔,一般送白玫瑰則代表着純潔的愛。通常...
2026-07-22
劉德華和梁朝偉哪個地位高點
劉德華和梁朝偉哪個地位高點
随着周潤發和成龍等老一代巨星逐漸進入半隐退狀态,在香港影壇的天皇巨星級演員中,劉德華和梁朝偉成為了絕對的代表。而且兩人在香港娛樂圈頗有淵源,論年齡1961年出生的劉德華比梁朝偉僅僅大一歲,而兩人出道的時間劉德華也剛好比梁朝偉早一年。所以在外...
2026-07-22
心算速算技巧
心算速算技巧
心算速算技巧?不進位的加法算式:(一定要先看清楚進不進位)兩位數加一位數:先寫上十位數,再接着寫上個位數的和兩位數加兩位數:先寫十位數的和,再寫個位數的和多位數加多位數:從高位起,依次寫上相同位上的數的和,我來為大家科普一下關于心算速算技巧...
2026-07-22
Copyright 2023-2026 - www.tftnews.com All Rights Reserved