Open utterances-bot opened 2 years ago
Hello, nice overview. The "pythonic" string mul code needs a small fix though, probably something like: T mul(T a, int b) { std::string ret{std::move(a)}; ret.reserve(ret.length() *b); auto start_pos{ret.begin()}; auto end_pos{ret.end()}; for (int i=1; i<b; ++i) { std::copy(start_pos, end_pos, std::back_inserter(ret)); } return ret; }
Yeah, that's right. I've made a change.
C++20 Concepts: The Definitive Guide - The Code Pad
This tutorial introduces C++20 concepts as a way to type-constrain templates, provide saner overload resolution, and throw better error messages.
https://thecodepad.com/cpp/c20-concepts-the-definitive-guide/