variadic template of c++0x

用 c++0x 里的可变参数模板(variadic template)几乎可以模仿函数式语言的 list 了。看下面,用 variadic template 可以定义 fold left(foldl)如下(test.cpp 是使用实例):

不过由于没法 typedef 可变参数模板,做不到返回 list 形态的模板,因此 map 的定义还是困难的。

更多有趣的内容可以看 What Does Haskell Have to Do with C++? 这篇 blog。

完整的源代码放在 github 上了。
闲谈:现在 git 用的顺手了点,于是就开始用 github。git 的分布式开发的特性决定了它 branch 和 merge 的功能相当强大。

This entry was posted in Computer and Internet, Programming and Algorithm and tagged , . Bookmark the permalink.

1 Response to variadic template of c++0x

  1. I’m very pleased to uncover this page. I want to to thank you for ones time just
    for this wonderful read!! I definitely liked every
    part of it and i also have you saved to fav to check
    out new stuff in your website.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s