如何通过 GUI 使用通用编程?
我使用通用编程技术开发了一个大型程序,其中涉及大量类模板。有没有办法根据 GUI 选项在运行时模拟选择这些参数?
假设我有 a
template <typename A, typename B, typename C>
class MyClass {};
,我想从 3 组单选按钮中选择 A、B 和 C。在不进行组合长 switch 语句的情况下,是否有任何方法可以使用用户在 GUI 中选择的类型来实例化 MyClass?
I have developed a big program using techniques of generic programming, which involve lots of class templates. Is there anyway to simulate choosing these parameters at runtime based on GUI options?
Say I have a
template <typename A, typename B, typename C>
class MyClass {};
and I want to choose A, B, and C from 3 groups of radio buttons. Without making a combinatorially long switch statement, is there any way to instantiate MyClass using the types that the user selects in the GUI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是这里的专家,但我确实相信,正如其他人在评论中提到的那样,这是不可能的。
您也许可以编写一个 GUI 应用程序来更改模板文件中的参数,并开始该项目的编译和执行。我们经常做类似的事情,以便使用不同的编译目标/环境对我们的代码进行单元测试,这听起来基本上就是您想要做的事情。
I am not an expert here, but I do believe that as others mentioned in comments that this isn't possible.
What you could perhaps do is write a GUI application that changed parameters in a template file, and kicked off the compilation and execution of this project. We often do similar things in order to unit test our code with different compilation targets/environments, and that sounds like essentially what you are trying to do.