问题使用STL std :: transform从cygwin g ++ [英] problems using STL std::transform from cygwin g++

查看:200
本文介绍了问题使用STL std :: transform从cygwin g ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cygwin上运行g ++(gcc版本3.4.4)。

I am running g++(gcc version 3.4.4) on cygwin.

我无法得到这小段代码来编译。

I can't get this small snippet of code to compile. I included the appropriate headers.

int main(){

    std::string temp("asgfsgfafgwwffw");

    std::transform(temp.begin(),
                   temp.end(),
                   temp.begin(),
                   std::toupper);

    std::cout << "result:" << temp << std::endl;

    return 0;
}



我没有使用STL容器如vector的任何问题。
任何人都有任何建议或洞察这种情况。
谢谢。

I have not had any issues using STL containers such as vector. Does anyone have any suggestions or insights into this situation. Thanks.

推荐答案

这很好地解释了这一点。

This explains it quite well.

这将归结为以下代码:

std::transform(temp.begin(),temp.end(),temp.begin(),static_cast<int (*)(int)>(std::toupper));

这篇关于问题使用STL std :: transform从cygwin g ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆