updated safe_operations.h for casting operations.