Search

template template parameters don't work with unions by Mathias Gaunard

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 684807
Opened: 8/19/2011 6:41:01 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
1
User(s) can reproduce this bug
Visual Studio 2010 refuses to pass union templates as template template parameters.

The following code fails to compile

template<template<class> class S>
struct test
{
};

template<class T>
union foo
{
};

int main()
{
    test<foo> t;
}

The error message is the following:
error C3200: 'foo' : invalid template argument for template parameter 'S', expected a class template

Changing foo to be a structure makes it work as expected.
Unions are classes, and this should work. It does work with other compilers like GCC or Clang.

This bug seriously impedes the usage of unions in code that makes use of meta-programming.
Unions can be necessary in the low-level details of high-performance code, a field where meta-programming techniques are quite popular.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 2010 SP1

Steps to reproduce

Try to compile snippet in description.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

The compilation fails.

Expected results

The compilation succeeds.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 8/22/2011 at 11:36 AM
Hi Mathias,
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by MS-Moderator09 [Feedback Moderator] on 8/21/2011 at 10:25 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 8/19/2011 at 7:41 AM
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)
Sign in to post a workaround.