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

線路代号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
推荐阅读
老童謠小時光系列
老童謠小時光系列
日本童謠《紅蜻蜓》赤とんぼ-改編/青木一男日本童謠《紅蜻蜓》赤とんぼ-改編/青木一男日本童謠《紅蜻蜓》赤とんぼ-改編/青木一男,
2026-07-27
鮑師傅肉松小貝口味測評
鮑師傅肉松小貝口味測評
如果你在魔都看到一條長長的隊伍卻不知道是幹嘛的,不用問了,一定是等着買“鮑師傅”的,據說每天排隊的長度都可以繞人民廣場好幾圈了,甚至苦等四五個小時就為了買一袋兒招牌“肉松小貝”的也大有人在!鮑師傅火爆到什麼程度?一言難盡全在圖裡▼為了吃也是...
2026-07-27
韭菜種子種植方法圖解幾天出苗
韭菜種子種植方法圖解幾天出苗
提要:韭菜種植方法多,老根移栽和種子播種,各有優勢韭菜也叫做“懶人菜”,因為韭菜屬于宿根植物,一次種植能夠連續好幾年,并且栽種方法也相對簡單。有朋友咨詢是種子播種韭菜好,還是直接移栽韭菜老根好。這裡科學興農就和大家看一下這個問題。​韭菜如何...
2026-07-27
20屆國際工業水處理技術及裝備展
20屆國際工業水處理技術及裝備展
2021年6月2日,第十四屆上海國際水處理展覽會于上海·國家會展中心如約召開,來自全國1000餘家水環境綜合治理、污水污泥綜合處理、過濾器材等行業内優秀參展商齊聚上海,共襄盛舉。本次展會,山東格瑞德集團有限公司攜隔膜壓濾機、一體化污水處理設...
2026-07-27
不尴尬不失禮貌的表達憤怒
不尴尬不失禮貌的表達憤怒
#頭條創作挑戰賽#“完了完了,真是要命,我又忍不住發火了。這真是讓人難過。”同事曉晨滿臉憂愁地說。發火憤怒是我們每個人都會碰到的事。憤怒是我們的基本情感。其實,憤怒除了表現為暴躁,還有其他的表現,比如撒潑耍性子,怄氣,任性,拖延。你可能會疑...
2026-07-27
Copyright 2023-2026 - www.tftnews.com All Rights Reserved