This is not C++ - you’re messing with at least three types in the last two lines…
Why the strange pointer approach when you can also use a simple index in the v vector?
You compare float elements with int values.
And you are not aware of the standard abs () function?
The counter itself is not used, because any out-of-range value will result in a negative outcome.
Why not stop at the first out-of-range value? You keep counting, even after a clipped value.
Then you use a C-cast on a boolean expression, to cast it to an int value 1, to be used as an increment. Thus “knowing” that a “true” is implemented the same as a “1” (but how many bytes?)
static_cast <int> (expression)
is proper C++ - but you don’t need that counting construct at all.
This is a much simpler, more readable and more efficient example:
... codeFor (const float* v, size_t n)
{
for (size_t i = 0; i < n; ++i)
if (std::abs (v[i]) > 1.0f)
return false; // or an enum value
Your method should return the defined enum as type, not an int. I’ll skip the use of the struct there…
Does your compiler not warn you? Is it set to a very old language standard?
I have been harsh in this thread, I said sorry twice and then tried to stay out of it, but if you now try to advise / educate people with such poor code, you deserve some serious feedback.