I'm having a bad time figuring this error out. I'll admit, I'm new to c++ and my difficulty comes from not understanding the error message.
Here's the code:
auto selectionFuncs[8] =
{
[&](const Vector3& min, const Vector3& max)
{
return max.x_ == seamValues.x_ || max.y_ == seamValues.y_ || max.z_ == seamValues.z_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.x_ == seamValues.x_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.z_ == seamValues.z_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.x_ == seamValues.x_ && min.z_ == seamValues.z_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.y_ == seamValues.y_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.x_ == seamValues.x_ && min.y_ == seamValues.y_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.y_ == seamValues.y_ && min.z_ == seamValues.z_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.x_ == seamValues.x_ && min.y_ == seamValues.y_ && min.z_ == seamValues.z_;
}
};
And here's the error:
error: ‘selectionFuncs’ declared as array of ‘auto’
From googling around, it seems using auto in this instance is not allowed in C++11 but it should be in C++14, however I must be declaring it wrong somehow and can't figure it out.
Help is very much appreciated, thank you!
The C++ language forbids having arrays declared with auto
. You have two good options: function pointers and even better - std::function
. Something like this:
std::function<bool(const Vector3&, const Vector3&)> selectionFuncs[8] =
{
[&](const Vector3& min, const Vector3& max)
{
return max.x_ == seamValues.x_ || max.y_ == seamValues.y_ || max.z_ == seamValues.z_;
},
[&](const Vector3& min, const Vector3& max)
{
return min.x_ == seamValues.x_;
},
// ...
};
Don't forget to #include <functional>
. Then you just use the elements of the array like any other functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With