gccがこのエラーを出力する理由を誰かに説明することはできますか?このコードでGCC vs variadicテンプレートコードのMSVCコンパイルエラー
/media/projects/src/libs/GUIElements/include/GUIElements/TemplatedFlagManager.h:195:
error: ‘ClearQueue’ was not declared in this scope
ClearQueue<QueueType>();
^
/media/projects/src/libs/GUIElements/include/GUIElements/TemplatedFlagManager.h:35: error:
‘typename std::enable_if<(I < sizeof... (Tp)), void>::type for_each(std::tuple<_Args2 ...>&, FuncT)
[with long unsigned int I = 1ul; FuncT = FlagNotifier<Args>::AddSubscriber(QSharedPointer<FlagSubscriber>)
[with Args = {SystemFlags::EAppFlags, SystemFlags::EQueueFlags, SystemFlags::EMessageFlags}]::<lambda(auto:2)>;
Tp = {QList<SystemFlags::EAppFlags>, QList<SystemFlags::EQueueFlags>, QList<SystemFlags::EMessageFlags>};
typename std::enable_if<(I < sizeof... (Tp)), void>::type = void]’,
declared using local type ‘FlagNotifier<Args>::AddSubscriber(QSharedPointer<FlagSubscriber>)
[with Args = {SystemFlags::EAppFlags, SystemFlags::EQueueFlags, SystemFlags::EMessageFlags}]::<lambda(auto:2)>’,
is used but never defined [-fpermissive]
for_each(std::tuple<Tp...>& t, FuncT f)
^
:
template <typename... Args>
class FlagNotifier
{
....
void AddSubscriber(QSharedPointer<FlagSubscriber> sub)
{
for_each(flagQueues, [&](auto queue){
using QueueType = typename decltype(queue)::value_type;
for(auto flag : queue)
{
auto& group = std::get<get_index<QueueType, Args...>::value>(flagGroups);
group[flag].push_back(sub);
}
ClearQueue<QueueType>();
sub->ApplyState();
});
}
template <typename T>
void ClearQueue(){
auto& flagQueue = std::get<get_index<T, Args...>::value>(this->flagQueues);
flagQueue.clear();
}
std::tuple<QList<Args>...> flagQueues;
std::tuple<QHash<Args, QList<QSharedPointer<FlagSubscriber>>>...> flagGroups;
}
MSVCはそれに完全に罰金です。 「オートキューは」そうタイプを簡単に推論する必要がありますし、まだこのあいまいな警告...
P.S.実際にタプル
std::tuple<QList<Args>...> flagQueues;
のメンバーであります
for_eachはこの質問から取得されます:stackoverflow.com/a/6894436/1143162
GET_INDEXここから:あなたはそれが依存としてそれを扱いたいのに対し、stackoverflow.com/a/18063608/1143162
をコンパイルに失敗 '何をfor_each'されますか? ClearQueueの問題は、インスタンス化時にのみ視覚的なチェック内容であるように見えます(1パス対2パス必要)。 – Jarod42
for_eachはここからタプル反復メカニズムです:https://stackoverflow.com/a/6894436/1143162 – Zeks
とget_indexはここからです:https://stackoverflow.com/a/18063608/1143162 – Zeks