diff --git a/src/algorithms.hpp b/src/algorithms.hpp index 5456417ddaea0e0fe6c4e777a0fa8ebf3344c2ed..37eeaf370acd54ef326f70cc4ae17e46f1c6f2b0 100644 --- a/src/algorithms.hpp +++ b/src/algorithms.hpp @@ -139,8 +139,9 @@ std::vector<typename C::value_type> child_count(const C& parent_index) template<typename C> bool has_contiguous_compartments(const C& parent_index) { + using value_type = typename C::value_type; static_assert( - std::is_integral<typename C::value_type>::value, + std::is_integral<value_type>::value, "integral type required" ); @@ -149,9 +150,9 @@ bool has_contiguous_compartments(const C& parent_index) } auto num_child = child_count(parent_index); - for (auto i = 1u; i < parent_index.size(); ++i) { + for (auto i=1u; i < parent_index.size(); ++i) { auto p = parent_index[i]; - if (num_child[p] == 1 && p != i-1) { + if (num_child[p]==1 && p!=value_type(i-1)) { return false; } } diff --git a/tests/unit/test_algorithms.cpp b/tests/unit/test_algorithms.cpp index ebe19c3752e9e4eacb23008e467bca9a1fd95f79..2e82bcc9a6effc4e0fdbb70bbad3d7cddf443aba 100644 --- a/tests/unit/test_algorithms.cpp +++ b/tests/unit/test_algorithms.cpp @@ -244,9 +244,9 @@ TEST(algorithms, has_contiguous_compartments) // // 0 - // / \ + // / \. // 1 2 - // / \ + // / \. // 3 4 // EXPECT_TRUE(