2
template <class T>
struct identity
{
    virtual ~identity() {}
    typedef T type;
};

template <class T>
struct _function_signature : _function_signature<decltype(&T::operator())>
{};

template <class R, class... A>
struct _function_signature<R(A...)> : identity<R(A...)>
{};

This piece of code compiles just fine in g++ but refuses to do so in msvc with the following error:

error C3520: 'A' : parameter pack must be expanded in this context

ms vs ultimate 2013 v 12.0.30110.00 update 1
g++ (rev5, Built by MinGW-W64 project) 4.8.1

Complete version of the errors:

1>------ Build started: Project: tests, Configuration: Debug Win32 ------
1>  main.cpp
1>d:\projects\tests\tests\main.cpp(30): error C3520: 'A' : parameter pack must be expanded in this context
1>          d:\tests\tests\main.cpp(162) : see reference to class template instantiation 'fl<void (void),>' being compiled
1>d:\projects\tests\tests\main.cpp(38): error C3520: 'A' : parameter pack must be expanded in this context
1>d:\projects\tests\tests\main.cpp(46): error C3520: 'A' : parameter pack must be expanded in this context
1>d:\projects\tests\tests\main.cpp(54): error C3520: 'A' : parameter pack must be expanded in this context
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Compiling version on stacked croocked.

Jarod42
  • 203,559
  • 14
  • 181
  • 302
Edward A
  • 2,291
  • 2
  • 18
  • 31
  • Just a side-note: Don't have names in the global namespace that starts with underscores, those names are reserved by the C++ specification. – Some programmer dude Feb 16 '14 at 14:27
  • @JoachimPileborg Its inside a couple of namespaces and inside another class, but thanks for the note. – Edward A Feb 16 '14 at 14:28
  • A `.cpp` file containing nothing but the above fails to compile on which line, and that is the only error message, is that right? Curious: why is `~identity` virtual, and does it matter for error? If you remove the base `template` implementation, does it matter? Do you have to instantiate to get the error? – Yakk - Adam Nevraumont Feb 16 '14 at 14:43
  • @Yakk Added the requested info + a compiling version of how it should work. – Edward A Feb 16 '14 at 15:15
  • Moving `_function_signature` specializations outside the class definition helps. – catscradle Feb 17 '14 at 13:49
  • I'm pretty sure this is a bug in MSVC -- [Clang](http://goo.gl/VdHvU0) and [ICC](http://goo.gl/SY1AXz) both accept this code... – LThode Dec 14 '15 at 18:35

0 Answers0