I am currently writing some glsl like vector math classes in C++, and I just implemented an abs() function like this:
abs()
template static
It probably just uses a bitmask to set the sign bit to 0.