Skip to content

Commit

Permalink
mapのコンセプトの引数順序修正
Browse files Browse the repository at this point in the history
  • Loading branch information
onihusube committed Jul 25, 2020
1 parent 70f74d2 commit bdca992
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/harmony.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ namespace harmony::detail {
[[no_unique_address]] F fmap;

template<unwrappable M>
requires detail::map_reusable<M, F&> and
requires detail::map_reusable<F&, M> and
not_void_resulted<F, traits::unwrap_t<M>>
friend constexpr specialization_of<monas> auto operator|(M&& m, map_impl self) noexcept(noexcept(std::forward<M>(m).map(self.fmap))) {
return monas(std::forward<M>(m).map(self.fmap));
Expand All @@ -725,7 +725,7 @@ namespace harmony::detail {
}

template<either M>
requires (not detail::map_reusable<M, F&>) and
requires (not detail::map_reusable<F&, M>) and
not_void_resulted<F, traits::unwrap_t<M>> and
either<std::remove_reference_t<std::invoke_result_t<F, traits::unwrap_t<M>>>>
friend constexpr specialization_of<monas> auto operator|(M&& m, map_impl self) {
Expand All @@ -747,7 +747,7 @@ namespace harmony::detail {
}

template<either M>
requires (not detail::map_reusable<M, F&>) and
requires (not detail::map_reusable<F&, M>) and
not_void_resulted<F, traits::unwrap_t<M>> and
(not either<std::remove_reference_t<std::invoke_result_t<F, traits::unwrap_t<M>>>>)
friend constexpr specialization_of<monas> auto operator|(M&& m, map_impl self) {
Expand Down Expand Up @@ -886,7 +886,7 @@ namespace harmony::detail {
[[no_unique_address]] F fmap;

template<either M>
requires (not and_then_reusable<F, M>) and
requires (not and_then_reusable<F&, M>) and
std::invocable<F, traits::unwrap_t<M>> and
either<std::invoke_result_t<F, traits::unwrap_t<M>>> and
std::constructible_from<std::remove_reference_t<std::invoke_result_t<F, traits::unwrap_t<M>>>, traits::unwrap_other_t<M>>
Expand All @@ -905,7 +905,7 @@ namespace harmony::detail {
}

template<either M>
requires and_then_reusable<F, M>
requires and_then_reusable<F&, M>
friend constexpr specialization_of<monas> auto operator|(M&& m, and_then_impl self) noexcept(noexcept(monas(std::forward<M>(m).and_then(self.fmap)))) {
return monas(std::forward<M>(m).and_then(self.fmap));
}
Expand Down Expand Up @@ -943,7 +943,7 @@ namespace harmony::detail {
[[no_unique_address]] F fmap;

template<either M>
requires (not or_else_reusable<F, M>) and
requires (not or_else_reusable<F&, M>) and
std::invocable<F, traits::unwrap_other_t<M>> and
either<std::invoke_result_t<F, traits::unwrap_other_t<M>>> and
std::constructible_from<std::remove_reference_t<std::invoke_result_t<F, traits::unwrap_other_t<M>>>, traits::unwrap_t<M>>
Expand All @@ -962,7 +962,7 @@ namespace harmony::detail {
}

template<either M>
requires or_else_reusable<F, M>
requires or_else_reusable<F&, M>
friend constexpr specialization_of<monas> auto operator|(M&& m, or_else_impl self) noexcept(noexcept(monas(std::forward<M>(m).or_else(self.fmap)))) {
return monas(std::forward<M>(m).or_else(self.fmap));
}
Expand Down
3 changes: 3 additions & 0 deletions test/harmony_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ int main() {

35_i == sum;
}

#ifndef _MSC_VER
{
using namespace std::string_view_literals;
tl::expected<int, std::string> ex{10};
Expand All @@ -387,6 +389,7 @@ int main() {
ut::expect(harmony::validate(r));
"22.0"sv == harmony::unwrap(r);
}
#endif // !_MSC_VER
};

"map_err test"_test = [] {
Expand Down

0 comments on commit bdca992

Please sign in to comment.