Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

c++ - C2977: 'std::tuple' : too many template arguments (MSVC11)

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);
}

That's an error text:

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'

And there is the line 72 of utility-file:

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...