For use max (A, B) and min (A, B) Function

For max (A, B) and min (A, B) in function of VS2013 in

These two functions in the header <algorithm> where A and B will be returned in the smaller / greater one.

And can not be changed _MIN _MAX. Check that works in Windows where you can replace this

URL: https: //zhidao.baidu.com/question/135498020.html

About using LInux with VC6 inside, CSDN a copy in the post answers

First, max () C ++ standard indeed it is a function rather than the actual macro definitions in different systems compiled as follows:
======================= ====================================
G ++ under linux, header <algorithm>
Template <class _TP >
inline const & _TP max (const __A _TP &, const _TP & __B) {
  return __A <__B __B: __A;?
}
========================= ==================================
VC6, header files under windows <algorithm> (latest VS.net not tried, not arrogantly)
Template <class _Ty> inline
const _Ty & _cpp_max (const & _Ty _X, const & _Ty data_Y)
{return (_X <data_Y data_Y: _X);?}
=========== ================================================

see ? g ++ it in accordance with the standard C ++ defines it as max (); VC6 given a free hand and turned it into _cpp_max ().
in fact, I have a question when attached source code is standard C ++ rules, in g ++ under successfully compiled, and because VC6 the max () becomes _cpp_max (), resulting in not compile.

To the VC6 with the max (), only the second best use _cpp_max (). Or _MAX ().
Because there is a header file xutility #define In another header file included in the algorithm _MAX _cpp_max

further has an associated macro __max, is defined in stdlib.h in: #define __max (a, b) (((a)> (b)) (a):? (b)), but __max not standard C ++, it was previously C-stay.

Released five original articles · won praise 0 · Views 6066

Guess you like

Origin blog.csdn.net/srplus/article/details/54911208