diff --git a/src/algorithms/rmq/rmq_sparse_table.h b/src/algorithms/rmq/rmq_sparse_table.h index 574ab3e8..c66f2b25 100644 --- a/src/algorithms/rmq/rmq_sparse_table.h +++ b/src/algorithms/rmq/rmq_sparse_table.h @@ -7,6 +7,18 @@ #include #endif +#ifndef count_leading_zeroes +#if defined(_MSC_VER) +# if defined(_M_ARM) || defined(_M_ARM64) +# define count_leading_zeroes(x) _CountLeadingZeros(x); +# else +# define count_leading_zeroes(x) __lzcnt(x); +# endif +#else +# define count_leading_zeroes(x) __builtin_clz(x); +#endif +#endif + /** * @brief credits to @nealwu for his RMQ query @@ -15,7 +27,7 @@ template struct RMQ { static int highest_bit(unsigned x) { - return x == 0 ? -1 : 31 - __builtin_clz(x); + return x == 0 ? -1 : 31 - count_leading_zeroes(x); } int n = 0; diff --git a/src/classes/list/skip_list.h b/src/classes/list/skip_list.h index f241005d..1b1afa77 100644 --- a/src/classes/list/skip_list.h +++ b/src/classes/list/skip_list.h @@ -11,6 +11,7 @@ #include #include #include +#include #endif /** diff --git a/tests/algorithms/sorting/minimum_swaps.cc b/tests/algorithms/sorting/minimum_swaps.cc index 4a4abb62..9371b016 100644 --- a/tests/algorithms/sorting/minimum_swaps.cc +++ b/tests/algorithms/sorting/minimum_swaps.cc @@ -3,7 +3,7 @@ #include #include #include - +#include TEST_CASE("Testing minimum swaps [1]") { std::vector a {3, 6, 4, 8}; @@ -28,8 +28,8 @@ TEST_CASE("Testing minimum swaps [3]") { TEST_CASE("Testing minimum swaps [4]") { std::vector a(100), b(100); - iota(a.begin(), a.end(), 1); - iota(b.begin(), b.end(), 1); + std::iota(a.begin(), a.end(), 1); + std::iota(b.begin(), b.end(), 1); std::swap(a[0], a[99]); REQUIRE(minimum_swaps(a, b) == 1); diff --git a/tests/machine_learning/image/image.cc b/tests/machine_learning/image/image.cc index 11bb89fa..3d5e0fc1 100644 --- a/tests/machine_learning/image/image.cc +++ b/tests/machine_learning/image/image.cc @@ -1,6 +1,7 @@ #include "../../../src/machine_learning/image/image.h" #include "../../../third_party/catch.hpp" #include +#include TEST_CASE("Testing default constructor of Image class") { std::vector > img = {{1,0,0}, {1,0,0}, {0,0,1}, {0,0,0}} ;