diff --git a/CMakeLists.txt b/CMakeLists.txt index 4312431..2d80ab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ endfunction() # Set standard function(setStandard target) - target_compile_features(${target} PRIVATE cxx_std_17) + target_compile_features(${target} PRIVATE cxx_std_14) endfunction() # Benchmarks @@ -80,4 +80,4 @@ option (BUILD_TESTING "Build the testing tree." ON) if (BUILD_TESTING) enable_testing() add_subdirectory(tests) -endif() \ No newline at end of file +endif() diff --git a/examples/physics.cpp b/examples/physics.cpp index f46f7f9..2fc25f9 100644 --- a/examples/physics.cpp +++ b/examples/physics.cpp @@ -15,8 +15,8 @@ struct Node std::vector generateRandomNodes(std::size_t n) { auto generator = std::default_random_engine(); - auto originDistribution = std::uniform_real_distribution(0.0f, 1.0f); - auto sizeDistribution = std::uniform_real_distribution(0.0f, 0.01f); + auto originDistribution = std::uniform_real_distribution(0.0f, 1.0f); + auto sizeDistribution = std::uniform_real_distribution(0.0f, 0.01f); auto nodes = std::vector(n); for (auto i = std::size_t(0); i < n; ++i) { @@ -65,7 +65,7 @@ int main() { return node->box; }; - auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); + auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); auto nodes = generateRandomNodes(n); // Add nodes to quadtree auto quadtree = Quadtree(box, getBox); @@ -74,7 +74,7 @@ int main() quadtree.add(&node); // Randomly remove some nodes auto generator = std::default_random_engine(); - auto deathDistribution = std::uniform_int_distribution(0, 1); + auto deathDistribution = std::uniform_int_distribution(0, 1); auto removed = std::vector(nodes.size(), false); std::generate(std::begin(removed), std::end(removed), [&generator, &deathDistribution](){ return deathDistribution(generator); }); @@ -105,4 +105,4 @@ int main() std::cout << intersections2.size() << '\n'; return 0; -} \ No newline at end of file +} diff --git a/include/Quadtree.h b/include/Quadtree.h index f4af30f..9971ec6 100644 --- a/include/Quadtree.h +++ b/include/Quadtree.h @@ -13,11 +13,19 @@ namespace quadtree template, typename Float = float> class Quadtree { +#if __cplusplus < 201703L + static_assert(std::is_convertible::type, Box>::value, +#else static_assert(std::is_convertible_v, Box>, +#endif "GetBox must be a callable of signature Box(const T&)"); +#if __cplusplus < 201703L + static_assert(std::is_convertible::type, bool>::value, +#else static_assert(std::is_convertible_v, bool>, +#endif "Equal must be a callable of signature bool(const T&, const T&)"); - static_assert(std::is_arithmetic_v); + static_assert(std::is_arithmetic::value, "is_arithmetic is false"); public: Quadtree(const Box& box, const GetBox& getBox = GetBox(), @@ -301,4 +309,4 @@ class Quadtree } }; -} \ No newline at end of file +} diff --git a/tests/tests.cpp b/tests/tests.cpp index fe9d5fb..c246be0 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -13,8 +13,8 @@ struct Node std::vector generateRandomNodes(std::size_t n) { auto generator = std::default_random_engine(); - auto originDistribution = std::uniform_real_distribution(0.0f, 1.0f); - auto sizeDistribution = std::uniform_real_distribution(0.0f, 0.01f); + auto originDistribution = std::uniform_real_distribution(0.0f, 1.0f); + auto sizeDistribution = std::uniform_real_distribution(0.0f, 0.01f); auto nodes = std::vector(n); for (auto i = std::size_t(0); i < n; ++i) { @@ -111,7 +111,7 @@ TEST_P(QuadtreeTest, AddAndQueryTest) { return node->box; }; - auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); + auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); auto nodes = generateRandomNodes(n); // Add nodes to quadtree auto quadtree = Quadtree(box, getBox); @@ -137,7 +137,7 @@ TEST_P(QuadtreeTest, AddAndFindAllIntersectionsTest) { return node->box; }; - auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); + auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); auto nodes = generateRandomNodes(n); // Add nodes to quadtree auto quadtree = Quadtree(box, getBox); @@ -158,7 +158,7 @@ TEST_P(QuadtreeTest, AddRemoveAndQueryTest) { return node->box; }; - auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); + auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); auto nodes = generateRandomNodes(n); // Add nodes to quadtree auto quadtree = Quadtree(box, getBox); @@ -166,7 +166,7 @@ TEST_P(QuadtreeTest, AddRemoveAndQueryTest) quadtree.add(&node); // Randomly remove some nodes auto generator = std::default_random_engine(); - auto deathDistribution = std::uniform_int_distribution(0, 1); + auto deathDistribution = std::uniform_int_distribution(0, 1); auto removed = std::vector(nodes.size()); std::generate(std::begin(removed), std::end(removed), [&generator, &deathDistribution](){ return deathDistribution(generator); }); @@ -206,7 +206,7 @@ TEST_P(QuadtreeTest, AddRemoveAndFindAllIntersectionsTest) { return node->box; }; - auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); + auto box = Box(0.0f, 0.0f, 1.0f, 1.0f); auto nodes = generateRandomNodes(n); // Add nodes to quadtree auto quadtree = Quadtree(box, getBox); @@ -214,7 +214,7 @@ TEST_P(QuadtreeTest, AddRemoveAndFindAllIntersectionsTest) quadtree.add(&node); // Randomly remove some nodes auto generator = std::default_random_engine(); - auto deathDistribution = std::uniform_int_distribution(0, 1); + auto deathDistribution = std::uniform_int_distribution(0, 1); auto removed = std::vector(nodes.size()); std::generate(std::begin(removed), std::end(removed), [&generator, &deathDistribution](){ return deathDistribution(generator); }); @@ -238,4 +238,4 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +}