我怎样才能在 C++ 中做到这一点?缺乏static_if将使事情变得更加困难。
template<typename T>
struct foo {
  foo() {
    //construction
    //if (T is an instantiation of some other template, say std::vector)
    //{
    //   stuff 1
    //}
  }
  void some_func() {
    //some code
    //if (T is an instantiation of some other template, say std::vector)
    //{
    //   stuff 2
    //}
  }
};
如果有任何帮助,这里的代码告诉我们是否T是另一个模板:
唯一的问题是如何将其转换为“如果”条件。