Variadic template pack expansion error - by Feindflug

Status : 

 


1
0
Sign in
to vote
ID 812102 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 12/20/2013 7:15:52 AM
Access Restriction Public

Description

The following codes generates an error while compiling:

[code]
struct A { struct Sub { int a; }; }; 
struct B { struct Sub { int b; }; }; 
struct C { struct Sub { int c; }; }; 
  
template< typename... CLASSES > 
struct Foo : public CLASSES::Sub... {}; 
  
int main() 
{ 
    Foo< A, B, C > x; 
    
    x.a = 1; 
    x.b = 2; 
    x.c = 3; 
}
[/code]

Error output:
error C2039: 'a' : is not a member of 'Foo<A,B,C>' 
error C2039: 'b' : is not a member of 'Foo<A,B,C>' 
error C2039: 'c' : is not a member of 'Foo<A,B,C>'
Sign in to post a comment.
Posted by Microsoft on 6/6/2014 at 9:53 AM
Thank you for using Visual Studio and for reporting this bug. We are happy to let you know that this issue has been fixed in Visual Studio 2013 Update 2. If you already have Visual Studio 2013, you can upgrade to Update 2 for free or you can install a trial version from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 1/24/2014 at 6:43 AM
Hi: a fix for this issue has been checked into the compiler sources. The fix should show up in a future release of Visual C++.

Thanks
Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 12/22/2013 at 11:07 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 12/20/2013 at 7:51 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)
Posted by Feindflug on 12/20/2013 at 7:18 AM
There is a workaround to get it going:

[code]
// identity template from decimad
template<typename T>
struct identity {
    using type = T;
};

struct A { struct Sub { int a; }; };
struct B { struct Sub { int b; }; };
struct C { struct Sub { int c; }; };

template< typename... CLASSES >
struct Foo : public identity<CLASSES>::type::Sub... {};

int main()
{
    Foo< A, B, C > x;
    
    x.a = 1;
    x.b = 2;
    x.c = 3;
}
[/code]