I have an image function declared as
thresholding( const Image &imgSrc, Image &imgDest );
What happens if I do this;
Image img;
tresholding( img, img );
Is this well-defined? Because in this case img
is changed.
P.S: threshold
reads imgSrc
and if `imgSrc[i] < lowerThr -> imgDest[i] = 255 else imgDest[i] = 0
And to be more precise:
__m128i _mm_src = _mm_load_si128 ( any_value );
__m128i _mm_src = _mm_load_si128 ( (__m128i*) &imgSrc[0] );
__m128i _mm_dest = _mm_load_si128 ( (__m128i*) &imgDest[0] );
_mm_dest = mm_cmpgt_epi16 (a, thr);
Having multiple references with possibly differing type to one object (just as having multiple pointers to the same object) is not problematic. The behavior of the function may be fine too: An expression like
is well-defined for
imgSrc
andimgDest
referring to the same object. No problems with sequencing o.s. occur. You should check the documentation or the source forthreshold
though, too be sure - It may be implemented in a way that requiresimgSrc
to be constant throughout execution. You shouldn't make assumptions without knowledge of the implementation.