Use Is_X
from std_logic_1164
; it will return true
if your std_logic_vector
contains any of 'U', 'X', 'Z', 'W', '-'.
Is_X
will always return false
during synthesis (you can e.g. use Is_X('W')
to test whether you're in simulation or synthesis.)