[英]Determine size of std::array return type without a function call
I have a class B
that takes classes like A
as a template parameter.我有一个 class
B
,它将A
之类的类作为模板参数。
template<typename T>
class B{
///...
Each T
has an operator()()
that returns an std::array<double, N>
.每个
T
都有一个operator()()
,它返回一个std::array<double, N>
。 I would like each specialization B<T>
to be able to deduce N
without additional requirement on the T
s and without calling the operator()()
.我希望每个专业化
B<T>
能够推断N
而不需要对T
s 有额外的要求,也不需要调用operator()()
。 How can I do this?我怎样才能做到这一点?
An example T
is below and labelled as class A
:下面是一个示例
T
并标记为class A
:
template <int N>
class A {
public:
A() {}
std::array<double, N> operator()() {
std::array<double, N> the_integers;
for (int i = 0; i < N; ++i) {
the_integers[i] = i;
}
return the_integers;
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.