Boost.Lambdaバインド式を見てください。それらを使用して、メンバー関数とメンバーデータをバインドできます。
使用しているタイプに関する十分な情報がありませんが、次のようなものが機能するはずです。
bind(&std::pair<S, R>::first,
bind(&Connection<T>::pair,
bind(&std::pair<U, Connection<T> >::second, _1))) == r
注:bind
このサンプルのは、boost::lambda
名前空間にあるものであり、Boost.Bindではありません。
編集:完全でコンパイル可能な例:
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
// http://stackoverflow.com/questions/12026884/expressing-1-second-pair-first-r-in-boostlambda/
typedef int S;
typedef int R;
template <typename T>
struct Connection
{
std::pair<S, R> pair() const {
return std::make_pair(0, 0);
}
};
int main()
{
using namespace boost::lambda;
typedef int T;
typedef int U;
std::vector<std::pair<U, Connection<T> > > vec;
vec.push_back(std::make_pair(3, Connection<T>()));
std::vector<bool> res(vec.size());
int r = 0;
std::transform(vec.begin(), vec.end(), res.begin(),
bind(&std::pair<S, R>::first,
bind(&Connection<T>::pair,
bind(&std::pair<U, Connection<T> >::second, _1))) == r);
std::vector<bool>::iterator it, end = res.end();
for (it = res.begin(); it != end; ++it) {
std::cout << ' ' << *it;
}
std::cout << std::endl;
}