Soft_Job 板


LINE

#每日新闻 # 2020-2-29 每日新闻 # FB: http://bit.ly/2UizW6X # C++是不是该有个transform_to函数? 在js叫map的功能 ```javascript= function getOldValues() { return ["a", "b", "c", "d"]; } var newValues = getOldValues().map(v => v.charCodeAt(0)); // result: [97, 98, 99, 100] ``` 在C#叫Select的功能 ```C# string[] GetOldValues() => new[] { "a", "b", "c", "d" }; var newValues = GetOldValues().Select(v => (int)v[0]).ToArray(); // result: int[] { 97, 98, 99, 100 }; ``` 在C++文章作者说他找不到所以自己写了一个 楼下有人回答他C++20有了 ```cpp auto toCharCode = [](auto&& v) -> int { return v[0]; }; auto oldValues = GetOldValues(); auto newValues = oldValues | std::views::transform(toCharCode); ``` http://bit.ly/32MwmEF # 现代C++ type trait 快速入门 文章有举个例 ```cpp void algorithm_signed (int i) { /*...*/ } void algorithm_unsigned(unsigned u) { /*...*/ } template <typename T> void algorithm(T t) { if constexpr(std::is_signed<T>::value) algorithm_signed(t); else if constexpr (std::is_unsigned<T>::value) algorithm_unsigned(t); else static_assert(std::is_signed<T>::value || std::is_unsigned<T>::value, "Must be signed or unsigned!"); } ``` 可以透过trait去判断执行的函数或是编译失败 http://bit.ly/2T9NRvq # C++: 为什麽我使用 references 在C++中使用 pointers 总是伴随着危险 如果可以,我们应该尽可能的只使用references 下面有使用 references 的优点 如果我不需要更改输入参数,则将使用const引用。 如果需要该参数的副本,则可以按值接受它并移动它。 如果需要更改输入参数,我将接受输入引用。但一般来说, 我更喜欢传值并返回一个副本。 我避免掉输出参数。 我使用引用和const引用进行区域命名。 我避免了右值references http://bit.ly/385Gw4d # C++20 设计 initializers C++20中有新的初始化语法 可以针对参数初始化 ```cpp struct bar { int x; }; struct foo { int a; bar b; char c = 'a'; double d; }; foo f1{}; // OK: a = 0, b = {x = 0}, c = 'a', d = 0.0 foo f2{ .a = 42 }; // OK: a = 42, b = {x = 0}, c = 'a', d = 0.0 foo f3{ .a = 42, .c = 'b' }; // OK: a = 42, b = {x = 0}, c = 'b', d = 0.0 foo f4{ .a = 42, .b = {.x = 5} }; // OK: a = 42, b = {x = 5}, c = 'a', d = 0.0 foo f5{ .a = 42, .b = {5} }; // OK: a = 42, b = {x = 5}, c = 'a', d = 0.0 ``` http://bit.ly/2whEOze # Bug Ghostcat影响过去13年所有Tomcat 由中国公司Chaitin Tech发现Ghostcat是Tomcat AJP协议中的缺陷。 Chaitin研究人员说,他们在AJP中发现了一个漏洞, 可以利用该漏洞读取文件或将文件写入Tomcat服务器。 Ghostcat漏洞广泛。它会影响所有6.x,7.x,8.x和9.x Tomcat分支。 Apache Tomcat 6.x於2007年2月发布, 这代表过去13年中发布的所有Tomcat版本都容易受到攻击。 https://zd.net/32zQZUa # Update4j Update4j是第一个为Java9+设计的自动更新和启动器库。 可以在任何地方轻松更新应用程式 (甚至包含Google Drive,Dropbox,Amazon S3,Maven Central) http://bit.ly/3cjfYQc # 使用 JDK Flight Recorder 持续观察程式 JFR是直接内置在Java运行时中的监视和故障排除框架。 JFR可以访问JVM的所有内部数据, 并且可以以极低的开销在获得非常细节的资讯并显示数据。 http://bit.ly/38bzgDG # 我要离开 golang 我跟Go语言的蜜月期已经结束。 我已经为该语言投入了数千小时的时间, 并使用了该语言对实作了一些关键的基础设施。 GO有许多优点,编译连结快速跨平台等等 这边要讲他的缺点 GO的简单是谎言 一遍又一遍,Go语言的每一份文档都将其称为“简单”。 准确地说,它是半个真相,可以轻松地掩盖一个事实, 当您将某些事情简化时,便会将复杂性转移到其他地方。 Golang把复杂性问题隐藏起来但从未解决。 文章的举例使用 unix 与 windows 档案文件做举例 还有档名包含 utf8 字串等等 还有副档名的判断 ``` Linux $ go run main.go "/" => "" "/." => "." "/.foo" => ".foo" "/foo" => "" "/foo.txt" => ".txt" "/foo.txt/bar" => "" "C:\\" => "" "C:\\." => "." "C:\\foo.txt" => ".txt" "C:\\foo.txt\\bar" => ".txt\\bar" $ cargo run --quiet / => None /. => None /.foo => None /foo. => Some("") /foo => None /foo.txt => Some("txt") /foo.txt/bar => None C:\ => None C:\. => Some("") C:\foo.txt => Some("txt") C:\foo.txt\bar => Some("txt\\bar") ``` ``` Windows $ go run main.go "/" => "" "/." => "." "/.foo" => ".foo" "/foo" => "" "/foo.txt" => ".txt" "/foo.txt/bar" => "" "C:\\" => "" "C:\\." => "." "C:\\foo.txt" => ".txt" "C:\\foo.txt\\bar" => "" $ cargo run --quiet / => None /. => None /.foo => None /foo. => Some("") /foo => None /foo.txt => Some("txt") /foo.txt/bar => None C:\ => None C:\. => None C:\foo.txt => Some("txt") C:\foo.txt\bar => None ``` http://bit.ly/3cmDT1k # Go monkeypatching Monkey通过在运行时改写正在运行的可执行文件 并插入跳转到您要调用的函数来实现Monkeypatching。 这听起来很不安全,我不建议任何人在测试环境之外进行操作。 http://bit.ly/2PA8vCs --
QR Code



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 111.249.0.195 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Soft_Job/M.1582960113.A.699.html
1F:推 plsmaop: monkey patching 怎麽在静态语言做到啊 02/29 15:42
2F:推 angle065: 推 02/29 21:14
3F:→ x000032001: 把page的write 权限打开来改..XD 02/29 22:13
4F:推 plsmaop: ......危险到爆 02/29 23:35







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:iOS站内搜寻

TOP