Algorithms, Ranges & Lambdas မှာcontainer ownership, iterator/range validity, algorithm preconditions နဲ့complexity ကိုတစ်ပြိုင်နက်စဉ်းစားပါ။ Hand-written loops များအစားstandard algorithms/ranges သုံးပြီးmutation နဲ့allocation policy ကိုရှင်းလင်းပါ။
ပိုပြီးနားလည်ထားရမယ့် အချက်
Algorithms, Ranges & Lambdas မှာcontainer ownership, iterator/range validity, algorithm preconditions နဲ့complexity ကိုတစ်ပြိုင်နက်စဉ်းစားပါ။ Hand-written loops များအစားstandard algorithms/ranges သုံးပြီးmutation နဲ့allocation policy ကိုရှင်းလင်းပါ။
လက်တွေ့မှာ ဘယ်လိုအသုံးချမလဲ
Algorithms, Ranges & Lambdas example ကိုempty, boundary, invalid နဲ့failure cases ဖြင့်စမ်းပြီး `-std=c++23 -Wall -Wextra -Wpedantic` နဲ့build ပါ။ Lifetime-sensitive code ကိုAddressSanitizer/UndefinedBehaviorSanitizer ဖြင့်ထပ်စစ်ပါ။
ဒီသင်ခန်းစာပြီးရင်
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector values{5, 2, 8, 1};
std::ranges::sort(values);
for (int value : values) std::cout << value << ' ';
}1 2 5 8ကိုယ်တိုင်စမ်းကြည့်ရန်
Algorithms, Ranges & Lambdas example ကိုempty, boundary, invalid နဲ့failure cases ဖြင့်စမ်းပြီး `-std=c++23 -Wall -Wextra -Wpedantic` နဲ့build ပါ။ Lifetime-sensitive code ကိုAddressSanitizer/UndefinedBehaviorSanitizer ဖြင့်ထပ်စစ်ပါ။
Memory/Safety သတိပေးချက်
Output တစ်ကြိမ်မှန်ရုံဖြင့် lifetime, bounds, ownership နဲ့undefined behavior အားလုံးမှန်ပြီဟုယူဆခြင်း။
The Current ISO C++ Standard (C++23) — Standard C++ Foundation