gpt4 book ai didi

gcc - GCC 4.8.1 : sorry, 未实现的解决方法:重整 argument_pack_select

转载 作者:行者123 更新时间:2023-12-03 20:27:12 28 4
gpt4 key购买 nike

考虑以下代码:

#include <tuple>

template <class Result, class Function, class... Types>
Result f(Function func, Types... values)
{
return std::get<0>(std::make_tuple(func(values)...));
}

template <class... Types>
int g(const Types... values)
{
return std::get<0>(std::make_tuple(f<Types>([](int n){return n;}, values)...));
}

int main()
{
return g(42);
}

在 g++ 4.8.1 下,它产生:

mangling.cpp: In instantiation of ‘g(const Types ...) [with Types = int]::__lambda0’:
mangling.cpp:12:50: required from ‘struct g(const Types ...) [with Types = int]::__lambda0’
mangling.cpp:12:77: required from ‘int g(const Types ...) [with Types = int]’
mangling.cpp:17:16: required from here
mangling.cpp:12:57: sorry, unimplemented: mangling argument_pack_select
return std::get<0>(std::make_tuple(f<Types>([](int n){return n;}, values)...));
^
mangling.cpp: In instantiation of ‘struct g(const Types ...) [with Types = int]::__lambda0’:
mangling.cpp:12:77: required from ‘int g(const Types ...) [with Types = int]’
mangling.cpp:17:16: required from here
mangling.cpp:12:57: sorry, unimplemented: mangling argument_pack_select
mangling.cpp:12:57: sorry, unimplemented: mangling argument_pack_select
mangling.cpp:4:8: error: ‘Result f(Function, Types ...) [with Result = int; Function = g(const Types ...) [with Types = {int}]::__lambda0; Types = {int}]’, declared using local type ‘g(const Types ...) [with Types = {int}]::__lambda0’, is used but never defined [-fpermissive]
Result f(Function func, Types... values)

是否有避免此问题的解决方法?是否已在 g++ 4.8.2 或 4.9.0 中报告和更正?

编辑:我刚刚在这里报告了错误:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60130

最佳答案

您是否需要为每个扩展参数创建一个新的 lambda?否则这将修复它:

template <class... Types>
int g(const Types... values)
{
auto func = [](int n){return n;};
return std::get<0>(std::make_tuple(f<Types>(func, values)...));
}

Live example

关于gcc - GCC 4.8.1 : sorry, 未实现的解决方法:重整 argument_pack_select,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21669666/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com