Q:

Bitwise NOT operation without the assignment operator - posible?

I know that I can do adding operation without assignment in this way intValue++ / ++intValue instead of intValue = intValue+1.
I would like to know if it is possible to do the same thing but with Bitwise NOT operation.
I guessed few syntax possibilities and the only that did not end with compile error was ~~intValue. but I did not saw any change when I was printed the variable.
Why I want to do this:
I know that if I using assignment operation while performing the requested operation (This case: "bitwise not"), Then according to my logic, this is what happens in low level:

1) Allocate temporary memory area for the data type
2) Copy the value of intValue to the temporary memory area
3) Perform the requested operation on the temporary memory area (so
  the result is in the temporary area)
4) Copy the result from the temporary memory area to the memory area
  of intValue
5) I'm not really sure about this: deallocate the temporary memory
  area.

Now, I know that this is not really a problem if the variable stors small value.
But what if the variable is an array of RGB colors (image data) ? This is my case. If what I wrote here is correct, then this means that it do copies in order to perform the requested operation. This is case of heavy data.
So this is why I want to do "bitwise not" in this way.
Currently I am using function in OpenCV to perform the requested operation and this is how I did it:
Mat matValue = imread("bmpTest.bmp", CV_LOAD_IMAGE_COLOR);
bitwise_not(matValue, matValue);
imshow("test", matValue);
waitKey(0);

Because that the second parameter of this function is dst (destination), then I am afraid that the way of how this function dones the operation is the 4 or 5 steps I described above. 
NOTE: If there is wording problem in this question - please suggest me how to fix the question. English is not my natural language. I'm sorry in a case that I was not clear enough.
Thanks for the helpers.

A:

OpenCV is smart enough to avoid memory allocations and copies when they aren't needed.
Since your src and dst matrices in bitwise_not(src, dst) are the same, you don't allocate new memory and you don't copy results. You perform this operation in-place.
In practice, what happens is like:

create the destination matrix

if dst is equal to src, don't allocate anything. Make dst to point to the same data as src
else allocate dst the same size and type of src

perform the operation: dst(i) = op(src(i)) (where op in this case is the bitwise not)

Note that:
bitwise_not(src, dst);
dst = ~src;

are not exactly equivalent, but at the end dst = ~src will call bitwise_not(src, dst). 

