C2977:“std::tuple":模板参数过多 (MSVC11) [英] C2977: 'std::tuple' : too many template arguments (MSVC11)

查看:44
本文介绍了C2977:“std::tuple":模板参数过多 (MSVC11)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Visual C++ 11 构建 googletest,但以下代码会导致错误

I'm trying to build googletest with Visual C++ 11, but following code causes an error

template <typename T1, typename T2, typename T3, typename T4, typename T5,
          typename T6, typename T7, typename T8, typename T9>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t, // <-- error C2977
             ::std::ostream* os) {
  PrintTupleTo(t, os);
}

这是一个错误文本:

f:gtest-1.6.0includegtestgtest-printers.h(550): error C2977: 'std::tuple' : too many template arguments
  c:program files (x86)microsoft visual studio 11.0vcincludeutility(72) : see declaration of 'std::tuple'

还有utility-file的第72行:

And there is the line 72 of utility-file:

template<class = _Nil, _MAX_CLASS_LIST>
   class tuple; // Line 72

std::tuple 有什么问题以及如何解决?

What is the problem with std::tuple and how to fix it?

(顺便说一句:我尝试将 std::tr1::tuple 更改为 std::tuple 失败)

(BTW: I'm tried unsuccessfully to change std::tr1::tuple to std::tuple )

推荐答案

查看 msdn 博客.VC++11 不支持可变参数模板.他们有一些他们称之为人造可变参数的东西.向下滚动,你会看到一个关于 Faux variadics 的段落,它讨论了元组.在该段中,他们说默认的最大参数数为 5.您可以将其增加到 10:

Check out this entry in the msdn blog. VC++11 doesn't have support for variadic templates. They have something they call faux variadics. Scroll down and you will see a paragraph on Faux variadics that talks about tuples. On that paragraph they say the default maximum number of parameters is 5. You can increase it to 10:

您可以在 5 到 10 之间定义 _VARIADIC_MAX 项目范围(默认为 5).增加它会使编译器消耗更多内存,并且可能需要您使用/Zm 选项为 PCHe 保留更多空间.

You can define _VARIADIC_MAX project-wide between 5 and 10 inclusive (it defaults to 5). Increasing it will make the compiler consume more memory, and may require you to use the /Zm option to reserve more space for PCHes.

他们说他们有一个修复方法可以再次将默认值设为 10.

They say they have a fix incoming to make the default 10 again.

这篇关于C2977:“std::tuple":模板参数过多 (MSVC11)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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