![]() |
Home | Libraries | People | FAQ | More |
同様に対応するヘルパ関数も提供する。
標準ライブラリにあるそれらの代わりに、これらのアダプタを使う主な便益 は、それらが 参照の参照 問題を回避することにある。
使い方は標準バインダと同様である。例えば、
class Foo { public: void bar(std::ostream &); // ... }; // ... std::vector<Foo> c; // ... std::for_each(c.begin(), c.end(), boost::bind2nd(boost::mem_fun_ref(&Foo::bar), std::cout));
以下の使用例を考えなさい。
class Foo { public: void bar(std::ostream &); // ... }; // ... std::for_each(c.begin(), c.end(), boost::bind2nd(boost::mem_fun_ref(&Foo::bar), std::cout));
これがもし
この問題は
template <class Operation> class binder2nd : public unary_function<typename Operation::first_argument_type, typename Operation::result_type> { ... public: binder2nd(const Operation& x, const typename Operation::second_argument_type& y); ...
我々の Operation の
このライブラリのバインダは Boost
コンストラクタは以下のように宣言される。
binder2nd(const Operation& x, typename call_traits< typename binary_traits<Operation>::second_argument_type >::param_type y)
結果、y は
Copyright © 2000 Cadenza New Zealand Ltd. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
Revised 28 June 2000
Japanese Translation Copyright (C) 2003 shinichiro.h <g940455@mail.ecc.u-tokyo.ac.jp>.
オリジナルの、及びこの著作権表示が全ての複製の中に現れる限り、この文書の 複製、利用、変更、販売そして配布を認める。このドキュメントは「あるがまま」 に提供されており、いかなる明示的、暗黙的保証も行わない。また、 いかなる目的に対しても、その利用が適していることを関知しない。