Fix compilation under MSVC

Use template for std::min and std::max
Fix indentation
Use of clamp
Little mistake
Try to fix compilation
Mistake
Indentation
Merge pull request #387 from conde2/master

Fix compilation under MSVC