From 821e1b2b4dc5792163c3840c5806a84982772144 Mon Sep 17 00:00:00 2001 From: AnhBe0 Date: Fri, 14 Jul 2023 11:26:21 -0400 Subject: [PATCH] Fix complier errors on MSVC --- examples/raytracing/example_raytracing.cpp | 2 +- src/ArborX_BruteForce.hpp | 2 +- src/ArborX_LinearBVH.hpp | 2 +- .../ArborX_DetailsCrsGraphWrapperImpl.hpp | 24 +++++++++---------- test/tstQueryTreeManufacturedSolution.cpp | 1 + test/tstRay.cpp | 16 ++++++------- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/examples/raytracing/example_raytracing.cpp b/examples/raytracing/example_raytracing.cpp index 4198904a09..e00273858d 100644 --- a/examples/raytracing/example_raytracing.cpp +++ b/examples/raytracing/example_raytracing.cpp @@ -293,7 +293,7 @@ int main(int argc, char *argv[]) Kokkos::rand::draw(g, dz)}; float upsilon = - Kokkos::rand::draw(g, 2.f * M_PI); + Kokkos::rand::draw(g, 2.f * Kokkos::numbers::pi_v); float theta = acos(1 - 2 * Kokkos::rand::draw(g)); ArborX::Experimental::Vector direction{ diff --git a/src/ArborX_BruteForce.hpp b/src/ArborX_BruteForce.hpp index a015f461e4..eff7d5bd37 100644 --- a/src/ArborX_BruteForce.hpp +++ b/src/ArborX_BruteForce.hpp @@ -53,7 +53,7 @@ class BruteForce template - std::enable_if_t>{}> + std::enable_if_t>::value> query(ExecutionSpace const &space, Predicates const &predicates, CallbackOrView &&callback_or_view, View &&view, Args &&...args) const { diff --git a/src/ArborX_LinearBVH.hpp b/src/ArborX_LinearBVH.hpp index 083957ba64..8f4d39e89d 100644 --- a/src/ArborX_LinearBVH.hpp +++ b/src/ArborX_LinearBVH.hpp @@ -76,7 +76,7 @@ class BasicBoundingVolumeHierarchy template - std::enable_if_t>{}> + std::enable_if_t>::value> query(ExecutionSpace const &space, Predicates const &predicates, CallbackOrView &&callback_or_view, View &&view, Args &&...args) const { diff --git a/src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp b/src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp index dcbd6d4738..dddc41aedc 100644 --- a/src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp +++ b/src/details/ArborX_DetailsCrsGraphWrapperImpl.hpp @@ -293,8 +293,8 @@ struct Iota template -std::enable_if_t{} || - std::is_same{}> +std::enable_if_t || + std::is_same_v> allocateAndInitializeStorage(Tag, ExecutionSpace const &space, Predicates const &predicates, OffsetView &offset, OutView &out, int buffer_size) @@ -320,7 +320,7 @@ allocateAndInitializeStorage(Tag, ExecutionSpace const &space, template -std::enable_if_t{}> +std::enable_if_t> allocateAndInitializeStorage(Tag, ExecutionSpace const &space, Predicates const &predicates, OffsetView &offset, OutView &out, int /*buffer_size*/) @@ -346,8 +346,8 @@ allocateAndInitializeStorage(Tag, ExecutionSpace const &space, template -std::enable_if_t{} && - Kokkos::is_view{} && Kokkos::is_view{}> +std::enable_if_t::value && + Kokkos::is_view::value && Kokkos::is_view::value> queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space, Predicates const &predicates, Callback const &callback, OutputView &out, OffsetView &offset, @@ -420,7 +420,7 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space, template -inline std::enable_if_t{} && Kokkos::is_view{}> +inline std::enable_if_t::value && Kokkos::is_view::value> queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space, Predicates const &predicates, Indices &indices, Offset &offset, Experimental::TraversalPolicy const &policy = @@ -433,7 +433,7 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space, template -inline std::enable_if_t{}> +inline std::enable_if_t::value> queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space, Predicates const &predicates, Callback const &callback, OutputView &out, OffsetView &offset, @@ -448,8 +448,8 @@ queryDispatch(Tag, Tree const &tree, ExecutionSpace const &space, } template -std::enable_if_t{} && - !is_tagged_post_callback{}> +std::enable_if_t::value && + !is_tagged_post_callback::value> check_valid_callback_if_first_argument_is_not_a_view( Callback const &callback, Predicates const &predicates, OutputView const &out) @@ -458,8 +458,8 @@ check_valid_callback_if_first_argument_is_not_a_view( } template -std::enable_if_t{} && - is_tagged_post_callback{}> +std::enable_if_t::value && + is_tagged_post_callback::value> check_valid_callback_if_first_argument_is_not_a_view(Callback const &, Predicates const &, OutputView const &) @@ -468,7 +468,7 @@ check_valid_callback_if_first_argument_is_not_a_view(Callback const &, } template -std::enable_if_t{}> +std::enable_if_t::value> check_valid_callback_if_first_argument_is_not_a_view(View const &, Predicates const &, OutputView const &) diff --git a/test/tstQueryTreeManufacturedSolution.cpp b/test/tstQueryTreeManufacturedSolution.cpp index eb320a1616..6f2d563fc6 100644 --- a/test/tstQueryTreeManufacturedSolution.cpp +++ b/test/tstQueryTreeManufacturedSolution.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include diff --git a/test/tstRay.cpp b/test/tstRay.cpp index 7828d506fb..c05e7f9543 100644 --- a/test/tstRay.cpp +++ b/test/tstRay.cpp @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(intersects_box) { \ float t0; \ float t1; \ - constexpr auto inf = KokkosExt::ArithmeticTraits::infinity::value; \ + auto const inf = KokkosExt::ArithmeticTraits::infinity::value; \ BOOST_TEST(!ArborX::Experimental::intersection(ray, box, t0, t1)); \ BOOST_TEST((t0 == inf || t1 == -inf)); \ } while (false) @@ -250,10 +250,10 @@ BOOST_AUTO_TEST_CASE(ray_box_distance) { using ArborX::Box; using ArborX::Experimental::Ray; - - constexpr Box unit_box{{0, 0, 0}, {1, 1, 1}}; - constexpr auto inf = KokkosExt::ArithmeticTraits::infinity::value; - + // use const instead of constexpr because MSVC shows error(error:expression must have a constant value) + const Box unit_box{{0, 0, 0}, {1, 1, 1}}; + auto const inf = KokkosExt::ArithmeticTraits::infinity::value; + // clang-format off // origin is within the box BOOST_TEST(ArborX::Experimental::distance(Ray{{.5, .5, .5}, {1, 0, 0}}, unit_box) == 0.f); @@ -347,7 +347,7 @@ BOOST_AUTO_TEST_CASE(overlap_distance_sphere, { \ float t0; \ float t1; \ - constexpr auto inf = KokkosExt::ArithmeticTraits::infinity::value; \ + const auto inf = KokkosExt::ArithmeticTraits::infinity::value; \ BOOST_TEST(!ArborX::Experimental::intersection(ray, sphere, t0, t1)); \ BOOST_TEST((t0 == inf && t1 == -inf)); \ } while (false) @@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(ray_sphere_intersection, using ArborX::Sphere; using ArborX::Experimental::Ray; - constexpr Sphere unit_sphere{{0, 0, 0}, 1}; + const Sphere unit_sphere{{0, 0, 0}, 1}; // use const instead of constexpr because MSVC shows error(error:expression must have a constant value) auto const sqrtf_3 = std::sqrt(3.f); auto const sqrtf_2 = std::sqrt(2.f); @@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(intersects_triangle) { \ float t0; \ float t1; \ - constexpr auto inf = KokkosExt::ArithmeticTraits::infinity::value; \ + const auto inf = KokkosExt::ArithmeticTraits::infinity::value; \ BOOST_TEST(!ArborX::Experimental::intersection(ray, triangle, t0, t1)); \ BOOST_TEST((t0 == inf && t1 == -inf)); \ } while (false)