解析模板参数列表中的错误,预期标识符

时间:2018-12-23 14:11:05

标签: c++ eclipse c++14 mingw

我正在尝试在Eclipse Oxygen中使用MinGW GCC-6.3.0编译EnTT library(对于cpp14,版本2.7.3)。编译时出现以下错误:

Info: Internal Builder is used for build
g++ -std=c++1y -D__GXX_EXPERIMENTAL_CXX0X__ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++14 -o "source\\main.o" "..\\source\\main.cpp" 
In file included from c:\mingw\include\entt\entt.hpp:10:0,
                 from ..\source\includes.hpp:23,
                 from ..\source\main.cpp:1:
c:\mingw\include\entt\entity/helper.hpp: In function 'void entt::connect(entt::Sink<void(entt::Registry<Entity>&, Entity)>)':
c:\mingw\include\entt\entity/helper.hpp:56:19: error: parse error in template argument list
     sink.template connect<dependency<Entity, Dependency...>>();
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\mingw\include\entt\entity/helper.hpp:56:19: error: expected identifier
c:\mingw\include\entt\entity/helper.hpp: In function 'void entt::disconnect(entt::Sink<void(entt::Registry<Entity>&, Entity)>)':
c:\mingw\include\entt\entity/helper.hpp:79:19: error: parse error in template argument list
     sink.template disconnect<dependency<Entity, Dependency...>>();
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c:\mingw\include\entt\entity/helper.hpp:79:19: error: expected identifier

这是有问题的严格功能:

template<typename Entity, typename... Component>
void dependency(Registry<Entity> &registry, const Entity entity) {
    using accumulator_type = int[];
    accumulator_type accumulator = { ((registry.template has<Component>(entity) ? void() : (registry.template assign<Component>(entity), void())), 0)... };
    (void)accumulator;
}

template<typename... Dependency, typename Entity>
inline void connect(Sink<void(Registry<Entity> &, const Entity)> sink) {
    sink.template connect<dependency<Entity, Dependency...>>();
}

template<typename... Dependency, typename Entity>
inline void disconnect(Sink<void(Registry<Entity> &, const Entity)> sink) {
    sink.template disconnect<dependency<Entity, Dependency...>>();
}

0 个答案:

没有答案