The following code works but I would like to avoid the warning:
warning: 'fitness::vect_' should be initialized in the member initialization list [-Weffc++]
when it is compiled with the g++ -Weffc++
switch:
#include <array>
template<class T, unsigned N>
class fitness
{
public:
explicit fitness(T v)
{
static_assert(N, "fitness zero length");
vect_.fill(v);
}
private:
std::array<T, N> vect_;
};
int main()
{
fitness<double, 4> f(-1000.0);
return 0;
}
Should I ignore the warning? Is there a way to fill vect_
in the constructor initialization list (without changing its type)?
vect_()
orvect_{}
. – Constrictor