Skip to content

Commit

Permalink
Fixed compatibility issues with the Win32 API (skystrife#79)
Browse files Browse the repository at this point in the history
Win32 API defines min and max macros that collide with numeric_limits<T>::min() and numeric_limits<T>::max().
  • Loading branch information
797876 authored and skystrife committed Jun 2, 2018
1 parent 53605ec commit 05252dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/cpptoml.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ struct value_traits<T,

static value_type construct(T&& val)
{
if (val < std::numeric_limits<int64_t>::min())
if (val < (std::numeric_limits<int64_t>::min)())
throw std::underflow_error{"constructed value cannot be "
"represented by a 64-bit signed "
"integer"};

if (val > std::numeric_limits<int64_t>::max())
if (val > (std::numeric_limits<int64_t>::max)())
throw std::overflow_error{"constructed value cannot be represented "
"by a 64-bit signed integer"};

Expand All @@ -364,7 +364,7 @@ struct value_traits<T,

static value_type construct(T&& val)
{
if (val > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()))
if (val > static_cast<uint64_t>((std::numeric_limits<int64_t>::max)()))
throw std::overflow_error{"constructed value cannot be represented "
"by a 64-bit signed integer"};

Expand Down Expand Up @@ -1033,11 +1033,11 @@ get_impl(const std::shared_ptr<base>& elem)
{
if (auto v = elem->as<int64_t>())
{
if (v->get() < std::numeric_limits<T>::min())
if (v->get() < (std::numeric_limits<T>::min)())
throw std::underflow_error{
"T cannot represent the value requested in get"};

if (v->get() > std::numeric_limits<T>::max())
if (v->get() > (std::numeric_limits<T>::max)())
throw std::overflow_error{
"T cannot represent the value requested in get"};

Expand All @@ -1060,7 +1060,7 @@ get_impl(const std::shared_ptr<base>& elem)
if (v->get() < 0)
throw std::underflow_error{"T cannot store negative value in get"};

if (static_cast<uint64_t>(v->get()) > std::numeric_limits<T>::max())
if (static_cast<uint64_t>(v->get()) > (std::numeric_limits<T>::max)())
throw std::overflow_error{
"T cannot represent the value requested in get"};

Expand Down

0 comments on commit 05252dc

Please sign in to comment.