问题标签 [variadic]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c# - P/调用带有可变参数签名的函数
我有一个 C#.NET 2.0 CF 应用程序,它从具有以下签名的本机 DLL 导入函数:
我的 C# 应用程序 P/Invokes 该功能如下:
但是,当我调用 时MyObject.Foo
,我得到一个System.MissingMethodException
.
我需要改变什么才能使这项工作?
谢谢,保罗
编辑:如果我将导入定义更改为:
然后,调用:
它没有问题,所以它与我的__arglist
用法有关。
cocoa - Cocoa - 从另一个可变参数调用一个可变参数方法(NSString stringWithFormat 调用)
我有一个问题,[NSString strigWithFormat:format]
因为它返回一个 id,并且我有很多代码将 NSString var 更改为其他个人类型。但是编译器并没有阻止我在某些地方将 NSString 设置为另一种类型的对象。
因此,我正在编写一个 NSString 类别,并且我将替换所有对stringWithFormat
to的调用myStringWithFormat
。
代码是:
编译器告诉我“格式不是字符串文字,也没有格式参数”。
你有什么办法可以使这项工作吗?
c++ - VS2010 C++ 可变参数模板示例
我有一个类模板,但我似乎无法弄清楚如何执行 Variadic Template 样式的实例化。
到目前为止,这是我正在寻找的“代码”:
显然这不会编译:)。这个想法是创建一个类,该类可以在构造函数中存储传入的值(如果有的话..它可能只定义了 _Classname/U),以便稍后可以检索它们以传递给另一个函数中的 m_Functor。
第一:Variadic Template 甚至可以在 VS2010 中完成吗?我只是error C2143: syntax error : missing ',' before '...'
从该行的模板声明中遇到编译问题template<typename _Classname, typename... Args>
其次,我想要完成的事情可以完成吗?谢谢!
c++ - What is the appropriate way to retrieve the value of a C++ variadic template constant argument at position N?
I would like to know what is the correct way to retrieve the value of a variadic template constant argument at position N (N is known at compile time). For instance, let's say you have a template that receives a variadic number of function pointers as arguments, and you need to retrieve the second function pointer. For now, all I've been able to come up with is this...
... which, needless to say, is very hackish. Is there a better way to do this? Thanks.
EDIT:
Based on typedeftemplate's code, I made a version that can accept any type as the variadic template argument. It has been tested to work on an experimental build of GCC 4.6. I figured out it could be useful to somebody else so there it is...
c++ - 递归可变参数模板函数的编译错误
我在 Code::Blocks 中准备了一个简单的可变参数模板测试,但出现错误:
调用“OutputSizes()”没有匹配的函数
这是我的源代码:
我将 GNU GCC 与-std=C++0x
. 使用-std=gnu++0x
没有区别。
reflection - 反射的可变参数和数组定义的区别
我有以下两段代码:
然后我使用反射获得上述方法的方法实例。
m1.getParameters() 和 m2.getParameters() 返回等于类实例的列表。m1 的参数和 m2 的参数都表示为数组。但实际上它们并不相同。编译器不允许
问题是:
是否有任何标志指定参数是可变参数还是常规数组?
objective-c - Objective-C 中的可变长度参数
如何在 Objective-C 中创建具有可变长度参数的类方法?
例如,像 -arrayWithObjects 这样的方法:
c++ - 从 C++ 宏创建字符串列表和枚举列表
为了使我的代码更短更容易更改,我想替换类似的东西
使用宏,如 INIT(AAA, BBB, CCC); 但是当我尝试使用可变参数和字符串化做一个宏时,我得到一个错误,因为没有声明参数。
关于如何做到这一点的任何想法?
c++ - 传递对可变参数模板的引用
我正在开发一个事件库,但我遇到了可变参数模板的问题。
一切都很好,除了我不能将引用作为参数传递......
这是一个非常简化的示例,用于揭露我的问题。
当我将所有 DelayedSignal 实例注册到单个 std::list 实例中时,我想避免在类本身上使用模板,这就是我在构造函数上使用模板的原因。我也可以使用纯虚类作为所有 DelayedSignal 的基础,并将指向虚类的指针注册到 std::list 但我认为最好尽量减少虚方法的使用,我对这个问题真的很感兴趣......
正如您在此示例中看到的,如果 test02 和 test04 被激活,它们将返回错误。DelayedSignal_DebugHelper 几乎与 DelayedSignal 相同,除了它在最后一个构造函数上使用 ArgsBis(类模板参数)而不是 Args 模板(方法模板参数),否则它不起作用(与 DelayedSignal 一样)。Args 是被接受的,但尽管它们在同一个构造函数声明中,void(C::*func)(Args...)
但它并不被接受。ArgsBis... args
据我所知,只要没有引用,没有引用(DelayedSignal test04(&Signal<void, Klass>::fire, signal_01, k);
例如)或有多个参数(或没有)就没有问题。
有没有办法解决这个问题?
谢谢你。