CSDN首页文章C++ 之父 2024 年末重磅演讲 | 重新认识 C++:跨世纪的现代演进,建议大家都去看看,对于现代C++开发很有启发意义,随便摘一段代码,优美!
template<int N>
generator<int> fibonacci() // 生成前 N 个斐波那契数
{
int a = 0;
int b = 1;
int count = 0;
while (count < N) {
int next = a + b;
co_yield a;
a = b;
b = next;
count++;
}
}
for (auto v: fibonacci<10>()) // 只生成十个数:0,1,1,2,3,5,8,13,21,34
cout << v << '\n';
而Bjarne Stroustrup的个人网站上的资料更是非常丰富,大家可以去查看(此处体现英语的重要性,最起码要能阅读英文资料)。
而CSDN首页末尾现代C++白皮书英文版链接,语言之父亲自教导(其实是他的论文),让人兴奋。