MSVC2012 中未定义 std::greater [英] std::greater not defined in MSVC2012

查看:34
本文介绍了MSVC2012 中未定义 std::greater的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 std::greater 不再是 Visual Studio 2012 中 std 命名空间的一部分?我现在需要包含

How come that std::greater is no more part of the std namespace in Visual Studio 2012? I now need to include <functional>

我认为 STL 库在工具集之间保持不变

I thought STL libraries remained the same across toolsets

推荐答案

为什么 std::greater 不再是 Visual Studio 2012 中 std 命名空间的一部分?

How come that std::greater is no more part of the std namespace in Visual Studio 2012?

如果是这样,我会非常惊讶.

I'd be very surprised if that were the case.

我现在需要包含

不,您需要包含 因为它是定义所有标准函数对象的头文件,包括 greater.

No, you need to include <functional> since that's the header that defines all the standard function objects, including greater.

我认为 STL 库在工具集之间保持不变

I thought STL libraries remained the same across toolsets

他们应该是.但是标题允许包含其他标题,因此有时即使您没有包含正确的标题,您也会发现某些内容可用.但是你不能依赖它,正如你在这里发现的那样.始终包含您使用的事物所需的所有标头.

They should be. But headers are allowed to include other headers, so sometimes you'll find that something is available even if you haven't included the correct header. But you can't rely on that, as you've found here. Always include all the headers you need for the things you use.

这篇关于MSVC2012 中未定义 std::greater的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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