我有一个N
用静态函数表示维度点的类min
(逐个字段的最小字段)
template<typename T, std::size_t N>
class Point : public std::array<T,N>
{
public:
template<typename... Args>
Point(Args&&... args) : std::array<T,N>{{args...}} {}
// ...
static Point min(const Point&, const Point&) {
// ...
}
};
当我写的时候一切都很好
Point<float,3> a = {0.f, 1.f, 2.f};
Point<float,3> b = {2.f, 1.f, 0.f};
Point<float,3> c = Point<float,3>::min(a,b); // OK
但是如果我尝试使用std::accumulate
数组
Point<float,3> array[100] = ... ;
Point<float,3> min = std::accumulate(array, array+100, array[0], Point<float,3>::min); // Error
我收到一个错误:
error: cannot convert ‘Point<float, 3ul>’ to ‘float’ in initialization
adimx::Point<T,N>::Point(Args&&... args) : std::array<T,N>{{args...}}
这是std::accumulate
实现与我的构造函数不兼容的问题吗?