Skip to content

Commit 6636561

Browse files
committed
made header compatible with the windows.h min/max macros
1 parent 7540d1c commit 6636561

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

csv.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -830,12 +830,14 @@ namespace io{
830830
struct set_to_max_on_overflow{
831831
template<class T>
832832
static void on_overflow(T&x){
833-
x = std::numeric_limits<T>::max();
833+
// using (std::numeric_limits<T>::max) instead of std::numeric_limits<T>::max
834+
// to make code including windows.h with its max macro happy
835+
x = (std::numeric_limits<T>::max)();
834836
}
835837

836838
template<class T>
837839
static void on_underflow(T&x){
838-
x = std::numeric_limits<T>::min();
840+
x = (std::numeric_limits<T>::min)();
839841
}
840842
};
841843

@@ -964,7 +966,7 @@ namespace io{
964966
while(*col != '\0'){
965967
if('0' <= *col && *col <= '9'){
966968
T y = *col - '0';
967-
if(x > (std::numeric_limits<T>::max()-y)/10){
969+
if(x > ((std::numeric_limits<T>::max)()-y)/10){
968970
overflow_policy::on_overflow(x);
969971
return;
970972
}
@@ -995,7 +997,7 @@ namespace io{
995997
while(*col != '\0'){
996998
if('0' <= *col && *col <= '9'){
997999
T y = *col - '0';
998-
if(x < (std::numeric_limits<T>::min()+y)/10){
1000+
if(x < ((std::numeric_limits<T>::min)()+y)/10){
9991001
overflow_policy::on_underflow(x);
10001002
return;
10011003
}

0 commit comments

Comments
 (0)