サーバダウンにより3日遅れでお送りします。

Visual C++ 2008にはSTL/CLRなるものが存在します。簡単に言えば、STLを.NETマネージ型に対応させたものです。ちょっとそれで遊んでみようと思い、こんなコードを書きました。

#include <cliext/vector>
#include <cliext/algorithm>
#include <cliext/functional>
#include <functional>
#include <boost/functional.hpp>
 
bool my_eq(int l, int r)
{
    return l == r;
}
 
int main()
{
    cliext::vector<int> v;
    v.push_back(1); v.push_back(2); v.push_back(3);
    cliext::vector<int>::iterator it =
        cliext::find_if(v.begin(), v.end(), boost::bind1st(my_eq, 2));
}

cliext::bind1st(my_eq, 2)がだめでした。そうかptr_funがいるんだな、とcliext::ptr_fun(my_eq)と書けば、こっちにはptr_funがないとのこと。MSDNライブラリにも載っていなければ実際のヘッダにも存在しませんでした。cliext::bind1st(std::ptr_fun(だと混合型でアウト。std::bind1st(std::ptr_fun(にすると、gcヒープ上の逆参照をint&で受けようとしているとのことでダメ。もうだめかと思えば、なんとboost::bind1st(my_eq, 2)で出来たのでした。

ちなみにstd::tr1::bind, boost::bind, boost::lambda::bind, boost::lambdaで_1 == 2はすべて駄目でした。


スポンサード リンク

この記事のカテゴリ

  • ⇒ 似て非なるものたち