diff --git a/include/faker-cxx/helper.h b/include/faker-cxx/helper.h index abf61b009..8effb9ee5 100644 --- a/include/faker-cxx/helper.h +++ b/include/faker-cxx/helper.h @@ -49,7 +49,7 @@ T arrayElement(const std::array& data) return data[index]; } -template +template auto arrayElement(It start, It end) -> decltype(*::std::declval()) { auto size = static_cast(end - start); @@ -61,7 +61,7 @@ auto arrayElement(It start, It end) -> decltype(*::std::declval()) const std::integral auto index = number::integer(size - 1); - return start[index]; + return *(start + static_cast>(index)); } /** diff --git a/src/modules/datatype.cpp b/src/modules/datatype.cpp index 1558948c5..20fcf5710 100644 --- a/src/modules/datatype.cpp +++ b/src/modules/datatype.cpp @@ -13,21 +13,19 @@ bool boolean() bool boolean(double probability) { - if (probability != nan("")) + if (!std::isnan(probability)) { - double prob = probability; - - if (prob <= double(0.)) + if (probability <= double(0)) { return false; } - if (prob >= double(1.)) + if (probability >= double(1)) { return true; } - return double(number::decimal(0., 1.)) < prob; + return number::decimal(0., 1.) < probability; } return number::decimal(0., 1.) < 0.5;