I have an unsigned int variable that I want to cast to an int, as it may store a -1 value.
What is the best way to do this?

I tried this:

Code:
lastCharIndex_ui = static_cast<int>(lastCharIndex_ui);
as well as:

Code:
(int)lastCharIndex_ui;
and other things as well, but it doesn't appear to work since the compiler still complains about the comparison between a unsigned int and a signed int expression.