I am working on this small piece of code, though it works as i expected, but i need it to be optimized. Please suggest me some ideas.

Here is important piece of my code:

```
std::replace_if(inputImage,inputImage+ m_xDim*m_yDim*m_zDim, bind2nd(std::less<float>(), 0), 0); // replace the values <0 with 0 of array input

std::replace_if(inputImage,inputImage+ m_xDim*m_yDim*m_zDim, bind2nd(std::greater<float>(), 4095), 4095);   // replace the values >4095 with 4095 of array input

```

As you can see i am make the value of inputImage to be with in the range [0,4095]. But, it is obvious that this is not efficient code, becoz i can have a loop running and do the both jobs in once shot. But, that becomes C style rather than C++. 

Is there a way to use **replace\_if** and get the both things done in one shot.