std::transform using C++0x lambda expression

后端 未结 6 1129
灰色年华
灰色年华 2020-12-28 13:05

How is this done in C++0x?

std::vector myv1;
std::transform(myv1.begin(), myv1.end(), myv1.begin(),
               std::bind1st(std::multiplies         


        
6条回答
  •  囚心锁ツ
    2020-12-28 13:47

    Like this:

    vector myv1;
    transform(myv1.begin(), myv1.end(), myv1.begin(), [](double v)
    {
        return v*3.0;
    });
    

提交回复
热议问题