VS 2013.1不会扩展可变参数模板

时间:2014-02-16 14:23:46

标签: c++ c++11 visual-studio-2013 variadic-templates compiler-bug

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...)>
{};

这段代码在g++中编译得很好,但在msvc拒绝这样做,但出现以下错误:

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

错误的完整版本:

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 ==========

stacked croocked上编译版本。

0 个答案:

没有答案