I have a struct like this
struct Example {
Example() = default;
explicit Example(const cv::Point2f& landmark,
float Score = 0.0f,
float visibilityScore = 1.f,
float threshold = 0.5f)
: point(landmark),
score(Score),
visibilityScore(visibilityScore),
threshold(visibilityThreshold) {}
cv::Point2f point{0, 0};
float score{0.0f};
float visibilityScore{1.f};
float threshold{0.5f};
};
When I try to initialize individually like below, no compilation issue -
Example eg = {};
eg.point = cv::Point2f(0,0);
eg.visibilityScore = 2.f;
eg.score = 3.f;
eg.threshold = 0.5f;
When I try bracket initializer list like below, I get build error -
Example eg = {
.point = cv::Point2f(0, 0),
.score = 3.f,
.visibilityScore = 2.f,
.threshold = 0.5f};
Error -
no matching constructor for initialization of Example
note: candidate constructor not viable: cannot convert argument of incomplete type 'void' to 'const cv::Point2f' (aka 'const Point_<float>') for 1st argument
note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 4 were provided
note: candidate constructor not viable: requires 0 arguments, but 4 were provided
Question - Is it something to do with explicit or first constructor arg being const&?