【发布时间】:2018-02-09 22:08:32
【问题描述】:
算法文件中有简单的max()函数代码。也许它是 c++ 代码,但我在这里什么都不懂。有很多宏。你能解释一下如何理解这种类型的代码吗?以及为什么使用了很多#define?
// TEMPLATE FUNCTION max
template<class _Ty> inline
_Post_equal_to_(_Left < _Right ? _Right : _Left)
constexpr const _Ty& (max)(const _Ty& _Left, const _Ty& _Right)
_NOEXCEPT_OP(_NOEXCEPT_OP(_DEBUG_LT(_Left, _Right)))
{ // return larger of _Left and _Right
return (_DEBUG_LT(_Left, _Right) ? _Right : _Left);
}
template<class _Ty> inline
/* constexpr */ // TRANSITION
_Ty (max)(_XSTD initializer_list<_Ty> _Ilist)
{ // return leftmost/largest
return ((_STD max)(_Ilist, less<>()));
}
【问题讨论】:
-
第一个提示:模板仅是 c++;所以它不是 c(让我在你因为那个错误而被激怒之前为你删除它)
-
当然。我找到你了
标签: c++ preprocessor