Oct 14, 2014 at 1:11pm UTC
So I came upon this line I didn't understand
1 2 3 4 5 6 7 8
DLLIMPORT void lv_EQ_0100(int A, int B, double C, int * err)
{
try
{
cv::Mat * pA=(cv::Mat*)A;
cv::Mat * pB=(cv::Mat*)B;
*pA=*pB == C;
== means equals to for all I know. I only expect to see this in a form of an 'if' statement so how does this work here?
Something familier stuff:
1 2 3 4 5 6 7 8
DLLIMPORT void lv_GTEQ_0101(int A, int B, int C, int * err)
{
try
{
cv::Mat * pA=(cv::Mat*)A;
cv::Mat * pB=(cv::Mat*)B;
cv::Mat * pC=(cv::Mat*)C;
*pA=*pB>=*pC;
1 2 3 4 5 6 7 8
DLLIMPORT void lv_NOTEQ_0101(int A, int B, int C, int * err)
{
try
{
cv::Mat * pA=(cv::Mat*)A;
cv::Mat * pB=(cv::Mat*)B;
cv::Mat * pC=(cv::Mat*)C;
*pA=*pB != *pC;
As always, thanks in advance
Last edited on Oct 14, 2014 at 1:17pm UTC
Oct 14, 2014 at 1:17pm UTC
I might be wrong but an example equivalent sample:
1 2 3 4 5 6 7 8 9 10 11 12
bool result(true );
int a(8);
int b(9);
result = (a == b);
// result is now false
}
== has a higher precedence than =.
So, to me, it's not that much of a weird useage.
Last edited on Oct 14, 2014 at 1:18pm UTC
Oct 14, 2014 at 1:39pm UTC
The *pB is a cv::Mat
. There is the realm of overloaded relational operators that the code samples shed no light on. However, it would be uncivil for them to return anything but bool.
Oct 14, 2014 at 9:19pm UTC
*pA=*pB == C;
C is equal to the pointer pB which is stored in pointer pA
or
pointer pB is equal to C, not assigned to C, pointer pB stored to pointer pA
"=" is the assignment operator
"==" checks for equality
int i = 0; // assign
int x = 0;
int y = 1;
if (x == y)
// then do something, otherwise do not
maybe a statement
if (*pB == C)
*pA = *pB; // if true, assign
Last edited on Oct 14, 2014 at 9:29pm UTC
Oct 14, 2014 at 9:25pm UTC
*pA=*pB>=*pC;
pointer pB is greater than or equal to pointer pC, pointer pB is stored to pointer pA
if (*pB >= *pC)
// statement(s) here for if to execute, braces if more than one
Last edited on Oct 14, 2014 at 9:33pm UTC
Oct 14, 2014 at 9:27pm UTC
*pA=*pB != *pC;
pointer pB is not equal to pointer pC, pointer pB is stored to pointer pA
if (*pB != *pC)
// statement(s) to execute here, more than one statement uses braces
Last edited on Oct 14, 2014 at 9:32pm UTC