VC2013 requires algorithm for std::min, std::max
always use _Copy_s for VC