Specify template parameters at runtime

后端 未结 7 1055
遇见更好的自我
遇见更好的自我 2020-11-29 06:32

Consider the following template class

class MyClassInterface {
public:
  virtual double foo(double) = 0;
}

class MyClass
: pub         


        
相关标签:
7条回答
  • 2020-11-29 07:15

    It is technically *possible** - but it's not practical and it's almost certainly the wrong way to approach the problem.

    Is there some reason why P1, P2 and P3 can't be regular integer variables?


    *You could embed a C++ compiler and a copy of your source, then compile a dynamic library or shared object that implements your factory function for a given set of P1,P2,P3 - but do you really want to do that? IMO, that's an absolutely crazy thing to be doing.

    0 讨论(0)
提交回复
热议问题