![]() |
Home | Libraries | People | FAQ | More |
Copyright 1999-2004 Jaakko Jrvi, Gary Powell
Use, modification and distribution is subject to the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Table of Contents
Boost Lambda Library(簡稱為 BLL)是一個 C++ 模板庫,為 C++ 實現了 lambda abstractions
的形式。這個術語起源於函數式編程和 lambda 演算,一個 lambda abstraction 定義一個無名函數。BLL
的主要動機是為定義供 STL
算法使用的無名函數對像提供靈活性和便利性。在講解一個庫是什麼的時候,一行代碼往往勝過千言萬語,下面這一行輸出以空格分隔的某個 STL 容器 a 中的元素:
for_each(a.begin(), a.end(), std::cout << _1 << ' ');
表達式 std::cout << _1 << ' ' 定義了一個一元的函數對象。變量 _1 是這個函數的形式參數,相當於一個實際參數的 placeholder(佔位符)。在 for_each 的每一次迭代中,針對實際參數 a 中的元素調用這個函數。這個實際參數取代了佔位符,而這個函數體被求值。
BLL 的本質是讓你就像上面那個一樣,在緊挨著 STL 算法調用位置的上面,定義小的無名函數對象。
[STL94] The Standard Template Library. Hewlett-Packard Laboratories. 1994. www.hpl.hp.com/techreports .
[SGI02] The SGI Standard Template Library. 2002. www.sgi.com/tech/stl/.
[Jr00] The Lambda Library : Lambda Abstraction in C++. Turku Centre for Computer Science. Technical Report . 378. 2000. www.tucs.fi/publications.
[Jr01] The Lambda Library : Lambda Abstraction in C++. Second Workshop on C++ Template Programming. Tampa Bay, OOPSLA'01. . 2001. www.oonumerics.org/tmpw01/.
[tuple] The Boost Tuple Library. www.boost.org/libs/tuple/doc/tuple_users_guide.html . 2002.
[type_traits] The Boost type_traits. www.boost.org/libs/type_traits/ . 2002.
[ref] Boost ref. www.boost.org/libs/bind/ref.html . 2002.
[bind] Boost Bind Library. www.boost.org/libs/bind/bind.html . 2002.
[function] Boost Function Library. www.boost.org/libs/function/ . 2002.
[fc++] The FC++ library: Functional Programming in C++. www.cc.gatech.edu/~yannis/fc++/ . 2002.
|
Last revised: November 29, 2006 at 19:28:48 GMT |