Pebble Coding

ソフトウェアエンジニアによるIT技術、数学の備忘録

2024-01-01から1年間の記事一覧

C++20でstd::vectorを範囲forを逆順にする

C++11でstd::vectorを範囲forできるようになりましたが、逆順にはできませんでした。 C++20のrangesにより逆順で範囲forできるようになりました。 #include <vector> #include <ranges> std::vector<int> v = {0, 1, 2, 3}; for (const auto& a: v | std::views::reverse) { print</int></ranges></vector>…

swift5.7(Xcode14)で気になる機能

SE-0345 if let shorthand for shadowing an existing optional variable swift-evolution/proposals/0345-if-let-shorthand.md at main · apple/swift-evolution · GitHub 同じ変数名でunwrapする際に簡略化して書けるようになりました。 これ助かる。 Xcod…