Skip to content

Commit

Permalink
Merge pull request #105 from tcbrindle/pr/fix_msvc_warnings
Browse files Browse the repository at this point in the history
Fix MSVC warnings
  • Loading branch information
tcbrindle authored Jul 26, 2023
2 parents 87b50c5 + a753e28 commit eb8efa5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions include/flux/core/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ struct assert_fn {
constexpr void operator()(bool cond, char const* msg,
std::source_location loc = std::source_location::current()) const
{
if (cond) [[likely]] {
if (cond) {
return;
} else [[unlikely]] {
} else {
runtime_error(msg, std::move(loc));
}
}
Expand Down
24 changes: 15 additions & 9 deletions include/flux/op/set_adaptors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ struct set_symmetric_difference_adaptor
flux::read_at(self.base2_, cur.base2_cursor))) {
cur.state_ = cursor_type::first;
return;
}
else {
} else {
if(std::invoke(self.cmp_, flux::read_at(self.base2_, cur.base2_cursor),
flux::read_at(self.base1_, cur.base1_cursor))) {
cur.state_ = cursor_type::second;
Expand Down Expand Up @@ -366,9 +365,13 @@ struct set_symmetric_difference_adaptor
-> std::common_reference_t<decltype(flux::read_at(self.base1_, cur.base1_cursor)),
decltype(flux::read_at(self.base2_, cur.base2_cursor))>
{
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done)
return flux::read_at(self.base1_, cur.base1_cursor);
return flux::read_at(self.base2_, cur.base2_cursor);
using R = std::common_reference_t<decltype(flux::read_at(self.base1_, cur.base1_cursor)),
decltype(flux::read_at(self.base2_, cur.base2_cursor))>;
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done) {
return static_cast<R>(flux::read_at(self.base1_, cur.base1_cursor));
} else {
return static_cast<R>(flux::read_at(self.base2_, cur.base2_cursor));
}
}

template <typename Self>
Expand All @@ -384,11 +387,14 @@ struct set_symmetric_difference_adaptor
-> std::common_reference_t<decltype(flux::move_at(self.base1_, cur.base1_cursor)),
decltype(flux::move_at(self.base2_, cur.base2_cursor))>
{
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done)
return flux::move_at(self.base1_, cur.base1_cursor);
return flux::move_at(self.base2_, cur.base2_cursor);
using R = std::common_reference_t<decltype(flux::move_at(self.base1_, cur.base1_cursor)),
decltype(flux::move_at(self.base2_, cur.base2_cursor))>;
if (cur.state_ == cursor_type::first || cur.state_ == cursor_type::second_done) {
return static_cast<R>(flux::move_at(self.base1_, cur.base1_cursor));
} else {
return static_cast<R>(flux::move_at(self.base2_, cur.base2_cursor));
}
}

};
};

Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ endif()
if(MSVC)
target_compile_options(test-libflux PRIVATE /W4
/wd4459 # local variable name hides global variable
/wd4702 # unreachable code
)
endif()

Expand Down
4 changes: 2 additions & 2 deletions test/test_repeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ constexpr bool test_repeat()
// Check that internal iteration works as expected
{
auto counter = 0;
auto cur =
auto inner_cur =
flux::for_each_while(seq, [&](int) { return counter++ < 5; });
STATIC_CHECK(cur == 5);
STATIC_CHECK(inner_cur == 5);
}
}

Expand Down

0 comments on commit eb8efa5

Please sign in to comment.