![]() |
Home | Libraries | People | FAQ | More |
同様に対応するヘルパ関数も提供する。
標準のアダプタそれぞれから、以下の変更がなされている:
標準は
template <class S, class T, class A> class const_mem_fun1_t : public binary_function<T*, A, S> { public: explicit const_mem_fun1_t(S (T::*p)(A) const); S operator()(const T* p, A x) const; };
これはどういうことか?さて、我々が以下のように書くとき何が起こるかを 考えなさい。
struct Foo { void bar(int) const; }; const Foo *cp = new Foo; std::bind1st(std::mem_fun(&Foo::bar), cp);
我々は以下のようなものを効果的に含む
typedef Foo* first_argument_type;
次に
このハックは改良された バインダ と共に用い る場合十分では無いので、我々はメンバ関数アダプタの修正されたバージョンも 同様に提供しなければならなかった。
標準は
template <class S, class T, class A> class mem_fun1_t : public binary_function<T*, A, S> { public: explicit mem_fun1_t(S (T::*p)(A)); S operator()(T* p, A x) const; };
しかしながら、もし我々が引数を代わりに
つまり、
Boost の
S operator()(T* p, typename call_traits<A>::param_type x) const
我々は望ましい結果を引き出した - 参照の参照を生み出すことなく、効率性 を得たのだ。
call traits テンプレートはこの改良を実現するために使われる関数オブジェ
クト特性と call_traits の両方が部分特殊化版に頼っているので、この改良は部
分特殊化の機能を持つコンパイラでのみ有効である。そうでないコンパイラでは、
メンバ関数に渡される引数は(
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>.
オリジナルの、及びこの著作権表示が全ての複製の中に現れる限り、この文書の 複製、利用、変更、販売そして配布を認める。このドキュメントは「あるがまま」 に提供されており、いかなる明示的、暗黙的保証も行わない。また、 いかなる目的に対しても、その利用が適していることを関知しない。