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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<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 684807 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 8/19/2011 6:41:01 AM
Access Restriction Public


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.
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 EricLeong [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)