On Friday, October 30, 2015 at 4:33:40 PM UTC-4, Jeffrey Walton wrote:
>
> > please wrap function name max with parenthesis like this: 
> > (std::numeric_limits<int>::max)(). in misc.h 
> > Same applies to std::max in order to avoid warning C4003 and errors 
> C2589 
> > and C2059 on: x = std::numeric_limits<int>::max() when using windows 
> headers 
> > (e.g. windows.h). 
> > 
>

An audit shows we are not using std::min and std::max

    $ grep "std::max" *.h *.cpp
    misc.h:// can't use std::min or std::max in MSVC60 or Cygwin 1.1.0
    zdeflate.cpp:    unsigned int maxCodeBits = *std::max_element(codeBits, 
codeBits+nCodes);
    zinflate.cpp:    m_maxCodeBits = *std::max_element(codeBits, 
codeBits+nCodes);

An audit of numeric_limits<T>::max shows more usage (below). I like the 
proposed solution of using parenthesis because it avoids NOMINMAX. Using 
NOMINMAX has downsides, and requires us to either (1) avoid use of min() 
and max(), or (2) push and pop macros to ensure they don't cross-pollinate 
from a Crypto++ header.

Jeff

$ grep "::max" *.h *.cpp
asn.h:// VC60 workaround: std::numeric_limits<T>::max conflicts with MFC 
max macro
misc.h:#  define SIZE_MAX (std::numeric_limits<size_t>::max)()
misc.h:// can't use std::min or std::max in MSVC60 or Cygwin 1.1.0
misc.h:    if (n > std::numeric_limits<T1>::max()-m-1)
secblock.h:    // std::numeric_limits<size_type>::max() is not a constexpr, 
and Clang does not optimize it well.
datatest.cpp:            
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
files.cpp:            size = std::numeric_limits<std::streamsize>::max();

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com.
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to