本文介绍了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.0\include\gtest\gtest-printers.h(550): error C2977: 'std::tuple' : too many template arguments
  c:\program files (x86)\microsoft visual studio 11.0\vc\include\utility(72) : see declaration of 'std::tuple'

并且实用程序的第72行 -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?

(BTW:我尝试不成功更改 std :: tr1 :: tuple std :: tuple

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

推荐答案

请在中查看此条目。 VC ++ 11不支持可变参数模板。他们有一些他们称之为人为变化的东西。向下滚动,你会看到一个关于假的可变参数的段落,涉及元组。在该段中,他们说默认的最大参数数为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:

他们说他们有一个修复传入,再次使默认10。

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

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

08-01 22:13