2017-04-21 3 views
-1

私は通常、ハスケルのプログラマであり、C++でいくつかの作業をしています。 aと同等のものC++のベクタにあるファンクタマップと同等のもの

fmap a -> (a->b) -> fmap b 

(C++ベクター用) Boost_foreachは近いです。

+0

'のstd :: transform'? http://en.cppreference.com/w/cpp/algorithm/transform –

答えて

2

std::transformは、コンテナの場合はfmapに最も近いものです。

例:

std::vector<int> src{/*...*/}; 
std::vector<std::string> dst; 

std::transform(src.begin(), src.end(), std::back_inserter(dst), 
       [](int x){ return std::to_string(x); }); 
関連する問題