Adjusting Camera Pitch limit from blueprint to C++ translation correct?

I am trying to limit Camera Pitch Scale in according to character pose state.
Implementation in bp is working fine, but in C++ the character is always looking to the sky.

C++ version:

//If the limit is currently exceeded, set the boundary value
	if (!(GetControlRotation().Pitch > LocBottomValue) || !(GetControlRotation().Pitch < LocTopValue))
	{
		if ((abs(rot.Pitch - LocTopValue)) < (abs(rot.Pitch - LocBottomValue)))
		{
            FRotator rot = GetControlRotation();
			rot.Pitch = LocTopValue;
			MyControllerRef->SetControlRotation (rot);
		}
		else
		{
			FRotator rot = GetControlRotation();
			rot.Pitch = LocBottomValue;
			MyControllerRef->SetControlRotation(rot);
		}
	}

You have an extra NOT (!) operator in your first if and The single NOT operator should be outside the boolean OR (||) expression contained in parenthesis:

if (!((GetControlRotation().Pitch > LocBottomValue) || (GetControlRotation().Pitch < LocTopValue)))

Because of operator precedence, you can remove some parenthesis and condense to:

if (!(GetControlRotation().Pitch > LocBottomValue || GetControlRotation().Pitch < LocTopValue))

Thank You for helping to optimize the code, Thank You very much.

Thank You for help, You just solved my problem… Thank You very much.