首页
/
每日頭條
/
生活
/
線路代号30的表示方法
線路代号30的表示方法
更新时间:2026-08-02 04:26:04

線路代号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
推荐阅读
手抖并不是你想的那麼簡單
手抖并不是你想的那麼簡單
資料圖:民衆正在上網購物。(圖文無關)中新社記者呂明攝免費拿到6單58萬元的獎品!其中有金器、手表、相機、手機在淘寶挑戰一分鐘花完100萬廣東惠州的劉女士買到手抖“高不高興?多虧了我吧。”一分鐘花完58萬,劉女士的手還在抖,第一個電話打給了...
2026-08-02
超好用的下奶湯
超好用的下奶湯
新媽媽都希望可以用母乳喂養寶寶,但是有些時候母乳确實偏少。母乳喂養,杜宇寶寶的健康成長都是比較好的,能增強免疫力、提升智力、減少寶寶猝死症的發生、減少兒童期肥胖等等。但在現實生活中,新媽媽在産後的飲食、情緒、工作或睡眠失調造成肝氣郁結、氣血...
2026-08-02
畫簡單五一勞動節畫
畫簡單五一勞動節畫
圖片來自網絡,僅做分享,如有侵權請聯系删除哦哦,
2026-08-02
清代人物書畫作品
清代人物書畫作品
唐琏,字汝器,号介亭,别号栖雲山人,又稱松石老人,臯蘭縣(今蘭州市)人,生于乾隆二十年(1755年),卒于道光十六年(1836年),享年81歲。他一生坎坷,因為家庭貧苦,少年時就辍學,不幸于20歲喪偶,終于不複娶妻。24歲起拜栖雲山道長劉一...
2026-08-02
計算rm的公式
計算rm的公式
計算rm的公式?很多人在訓練時都比較清楚的是增肌要練8-12次,以此來達到肌肉肥大的目的,但不太清楚為什麼要練8-12次,或者說不知道8-12次的真正含義其實在訓練當中,次數隻是一個用來衡量你訓練強度的衡量單位,通常用RM來表示,意思是你每...
2026-08-02
Copyright 2023-2026 - www.tftnews.com All Rights Reserved