Templates & Concepts မှာcontainer ownership, iterator/range validity, algorithm preconditions နဲ့complexity ကိုတစ်ပြိုင်နက်စဉ်းစားပါ။ Hand-written loops များအစားstandard algorithms/ranges သုံးပြီးmutation နဲ့allocation policy ကိုရှင်းလင်းပါ။
ပိုပြီးနားလည်ထားရမယ့် အချက်
Templates & Concepts မှာcontainer ownership, iterator/range validity, algorithm preconditions နဲ့complexity ကိုတစ်ပြိုင်နက်စဉ်းစားပါ။ Hand-written loops များအစားstandard algorithms/ranges သုံးပြီးmutation နဲ့allocation policy ကိုရှင်းလင်းပါ။
လက်တွေ့မှာ ဘယ်လိုအသုံးချမလဲ
Templates & Concepts example ကိုempty, boundary, invalid နဲ့failure cases ဖြင့်စမ်းပြီး `-std=c++23 -Wall -Wextra -Wpedantic` နဲ့build ပါ။ Lifetime-sensitive code ကိုAddressSanitizer/UndefinedBehaviorSanitizer ဖြင့်ထပ်စစ်ပါ။
ဒီသင်ခန်းစာပြီးရင်
#include <concepts>
#include <iostream>
template <std::integral T>
T twice(T value) { return value * 2; }
int main() { std::cout << twice(21) << '\n'; }42ကိုယ်တိုင်စမ်းကြည့်ရန်
Templates & Concepts 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