C++ map<tuple<...>, V> compilation problems - by Bob 234567

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 534457 Comments
Status Resolved Workarounds
Type Bug Repros 1
Opened 2/18/2010 1:22:44 AM
Access Restriction Public


The following code does not compile in Visual Studio 2010 RC1:

#include <tuple>
#include <map>

using namespace std;

int main()

	map<tuple<int>,int> test;
	tuple<int> testKey(1);

	return 0;

The part that has been commented out does not cause any troubles, the problems only seems to occur when the key is passed through a variable.
Sign in to post a comment.
Posted by Petter S on 10/26/2011 at 12:37 PM
Good that is has been fixed. I installed SP1 for Visual Studio today and I am quite disappointed that it was not fixed therein.

This bug was reported 2/18/2010 for the release candidate. I had hope that the fix would at least make it to SP1.
Posted by Stephan [MSFT] on 6/29/2011 at 2:48 PM

Thanks again for reporting this bug. We've fixed it, and the fix will be available in VC11. (It involved a messy interaction between map, pair, and tuple.)

I apologize for the mangled history of this bug; we switched internal databases, and I ported this bug by hand to the new database so I could keep track of it. Unfortunately, someone went through the old database and resolved active bugs as Won't Fix. I don't know how to change the apparent status of this bug on Connect, but we've definitely fixed this.

As always, if you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Petter S on 6/27/2011 at 7:14 AM
I think it is absurd that this bug won't be fixed.
Posted by Raman [MSFT] on 3/23/2011 at 6:44 PM

Thanks for reporting this issue. At this stage we are unable to address this particular issue as there are other higher priority items for the team.

We appreciate your continued feedback and are constantly trying to incorporate it to make our product better.

Thank you
Visual C++ Team
Posted by Petter S on 3/15/2011 at 9:16 AM
This bug is rather annoying. Isn't there a temporary fix for the <tuple> header?

Will there be a service pack for VC++10 fixing this?
Posted by Stephan [MSFT] on 2/19/2010 at 6:04 PM

Thanks for reporting this bug. Unfortunately, while I'd love to fix this in VC10 RTM, it's too late - for stability, only major bugs without workarounds can be fixed between RC and RTM. Fortunately, a workaround exists for this bug.

As you noticed, passing temporary tuples to map's op[]() doesn't trigger this bug. Therefore, when you have a named tuple, you can construct a temporary from it and pass that to op[](). Here's an example:

C:\Temp>type meow.cpp
#include <iostream>
#include <map>
#include <ostream>
#include <tuple>
using namespace std;

int main() {
    typedef tuple<short, int, long> key_t;

    map<key_t, char> m;

    key_t t(40, 50, 60);

    m[key_t(t)] = 'X';
    m[key_t(10, 20, 30)] = 'Y';
    m[make_tuple(33, 22, 11)] = 'Z';

    for (auto i = m.cbegin(); i != m.cend(); ++i) {
        cout << "(" << get<0>(i->first)
            << ", " << get<1>(i->first)
            << ", " << get<2>(i->first)
            << "): " << i->second << endl;

C:\Temp>cl /EHsc /nologo /W4 meow.cpp

(10, 20, 30): Y
(33, 22, 11): Z
(40, 50, 60): X

(Note that make_tuple(33, 22, 11) returns tuple<int, int, int>, which is convertible to tuple<short, int, long>.)

I'm keeping this bug active so that it can be fixed in VC11.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 2/18/2010 at 10:18 PM
Thanks for your feedback. We were able to reproduce the issue you are seeing. We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/18/2010 at 7:03 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)