inline constexpr __none_of_fn none_of{};
template<typename _Iter, typename _Fp>
- struct for_each_result
+ struct in_fun_result
{
[[no_unique_address]] _Iter in;
[[no_unique_address]] _Fp fun;
template<typename _Iter2, typename _F2p>
requires convertible_to<const _Iter&, _Iter2>
&& convertible_to<const _Fp&, _F2p>
- operator for_each_result<_Iter2, _F2p>() const &
+ constexpr
+ operator in_fun_result<_Iter2, _F2p>() const &
{ return {in, fun}; }
template<typename _Iter2, typename _F2p>
requires convertible_to<_Iter, _Iter2> && convertible_to<_Fp, _F2p>
- operator for_each_result<_Iter2, _F2p>() &&
+ constexpr
+ operator in_fun_result<_Iter2, _F2p>() &&
{ return {std::move(in), std::move(fun)}; }
};
+ template<typename _Iter, typename _Fp>
+ using for_each_result = in_fun_result<_Iter, _Fp>;
+
struct __for_each_fn
{
template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
inline constexpr __for_each_fn for_each{};
template<typename _Iter, typename _Fp>
- using for_each_n_result = for_each_result<_Iter, _Fp>;
+ using for_each_n_result = in_fun_result<_Iter, _Fp>;
struct __for_each_n_fn
{
inline constexpr __count_if_fn count_if{};
template<typename _Iter1, typename _Iter2>
- struct mismatch_result
+ struct in_in_result
{
[[no_unique_address]] _Iter1 in1;
[[no_unique_address]] _Iter2 in2;
template<typename _IIter1, typename _IIter2>
requires convertible_to<const _Iter1&, _IIter1>
&& convertible_to<const _Iter2&, _IIter2>
- operator mismatch_result<_IIter1, _IIter2>() const &
+ constexpr
+ operator in_in_result<_IIter1, _IIter2>() const &
{ return {in1, in2}; }
template<typename _IIter1, typename _IIter2>
requires convertible_to<_Iter1, _IIter1>
&& convertible_to<_Iter2, _IIter2>
- operator mismatch_result<_IIter1, _IIter2>() &&
+ constexpr
+ operator in_in_result<_IIter1, _IIter2>() &&
{ return {std::move(in1), std::move(in2)}; }
};
+ template<typename _Iter1, typename _Iter2>
+ using mismatch_result = in_in_result<_Iter1, _Iter2>;
+
struct __mismatch_fn
{
template<input_iterator _Iter1, sentinel_for<_Iter1> _Sent1,
inline constexpr __is_permutation_fn is_permutation{};
template<typename _Iter, typename _Out>
- using copy_if_result = copy_result<_Iter, _Out>;
+ using copy_if_result = in_out_result<_Iter, _Out>;
struct __copy_if_fn
{
inline constexpr __copy_if_fn copy_if{};
template<typename _Iter1, typename _Iter2>
- using swap_ranges_result = mismatch_result<_Iter1, _Iter2>;
+ using swap_ranges_result = in_in_result<_Iter1, _Iter2>;
struct __swap_ranges_fn
{
inline constexpr __swap_ranges_fn swap_ranges{};
template<typename _Iter, typename _Out>
- using unary_transform_result = copy_result<_Iter, _Out>;
+ using unary_transform_result = in_out_result<_Iter, _Out>;
template<typename _Iter1, typename _Iter2, typename _Out>
- struct binary_transform_result
+ struct in_in_out_result
{
[[no_unique_address]] _Iter1 in1;
[[no_unique_address]] _Iter2 in2;
requires convertible_to<const _Iter1&, _IIter1>
&& convertible_to<const _Iter2&, _IIter2>
&& convertible_to<const _Out&, _OOut>
- operator binary_transform_result<_IIter1, _IIter2, _OOut>() const &
+ constexpr
+ operator in_in_out_result<_IIter1, _IIter2, _OOut>() const &
{ return {in1, in2, out}; }
template<typename _IIter1, typename _IIter2, typename _OOut>
requires convertible_to<_Iter1, _IIter1>
&& convertible_to<_Iter2, _IIter2>
&& convertible_to<_Out, _OOut>
- operator binary_transform_result<_IIter1, _IIter2, _OOut>() &&
+ constexpr
+ operator in_in_out_result<_IIter1, _IIter2, _OOut>() &&
{ return {std::move(in1), std::move(in2), std::move(out)}; }
};
+ template<typename _Iter1, typename _Iter2, typename _Out>
+ using binary_transform_result = in_in_out_result<_Iter1, _Iter2, _Out>;
+
struct __transform_fn
{
template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
inline constexpr __replace_if_fn replace_if{};
template<typename _Iter, typename _Out>
- using replace_copy_result = copy_result<_Iter, _Out>;
+ using replace_copy_result = in_out_result<_Iter, _Out>;
struct __replace_copy_fn
{
inline constexpr __replace_copy_fn replace_copy{};
template<typename _Iter, typename _Out>
- using replace_copy_if_result = copy_result<_Iter, _Out>;
+ using replace_copy_if_result = in_out_result<_Iter, _Out>;
struct __replace_copy_if_fn
{
inline constexpr __remove_fn remove{};
template<typename _Iter, typename _Out>
- using remove_copy_if_result = copy_result<_Iter, _Out>;
+ using remove_copy_if_result = in_out_result<_Iter, _Out>;
struct __remove_copy_if_fn
{
inline constexpr __remove_copy_if_fn remove_copy_if{};
template<typename _Iter, typename _Out>
- using remove_copy_result = copy_result<_Iter, _Out>;
+ using remove_copy_result = in_out_result<_Iter, _Out>;
struct __remove_copy_fn
{
inline constexpr __unique_fn unique{};
template<typename _Iter, typename _Out>
- using unique_copy_result = copy_result<_Iter, _Out>;
+ using unique_copy_result = in_out_result<_Iter, _Out>;
struct __unique_copy_fn
{
inline constexpr __reverse_fn reverse{};
template<typename _Iter, typename _Out>
- using reverse_copy_result = copy_result<_Iter, _Out>;
+ using reverse_copy_result = in_out_result<_Iter, _Out>;
struct __reverse_copy_fn
{
inline constexpr __rotate_fn rotate{};
template<typename _Iter, typename _Out>
- using rotate_copy_result = copy_result<_Iter, _Out>;
+ using rotate_copy_result = in_out_result<_Iter, _Out>;
struct __rotate_copy_fn
{
inline constexpr __partial_sort_fn partial_sort{};
template<typename _Iter, typename _Out>
- using partial_sort_copy_result = copy_result<_Iter, _Out>;
+ using partial_sort_copy_result = in_out_result<_Iter, _Out>;
struct __partial_sort_copy_fn
{
inline constexpr __stable_partition_fn stable_partition{};
- template<typename _Iter, typename _Out1, typename _O2>
- struct partition_copy_result
+ template<typename _Iter, typename _Out1, typename _Out2>
+ struct in_out_out_result
{
[[no_unique_address]] _Iter in;
[[no_unique_address]] _Out1 out1;
- [[no_unique_address]] _O2 out2;
+ [[no_unique_address]] _Out2 out2;
template<typename _IIter, typename _OOut1, typename _OOut2>
requires convertible_to<const _Iter&, _IIter>
&& convertible_to<const _Out1&, _OOut1>
- && convertible_to<const _O2&, _OOut2>
- operator partition_copy_result<_IIter, _OOut1, _OOut2>() const &
+ && convertible_to<const _Out2&, _OOut2>
+ constexpr
+ operator in_out_out_result<_IIter, _OOut1, _OOut2>() const &
{ return {in, out1, out2}; }
template<typename _IIter, typename _OOut1, typename _OOut2>
requires convertible_to<_Iter, _IIter>
&& convertible_to<_Out1, _OOut1>
- && convertible_to<_O2, _OOut2>
- operator partition_copy_result<_IIter, _OOut1, _OOut2>() &&
+ && convertible_to<_Out2, _OOut2>
+ constexpr
+ operator in_out_out_result<_IIter, _OOut1, _OOut2>() &&
{ return {std::move(in), std::move(out1), std::move(out2)}; }
};
+ template<typename _Iter, typename _Out1, typename _Out2>
+ using partition_copy_result = in_out_out_result<_Iter, _Out1, _Out2>;
+
struct __partition_copy_fn
{
template<input_iterator _Iter, sentinel_for<_Iter> _Sent,
inline constexpr __partition_point_fn partition_point{};
template<typename _Iter1, typename _Iter2, typename _Out>
- using merge_result = binary_transform_result<_Iter1, _Iter2, _Out>;
+ using merge_result = in_in_out_result<_Iter1, _Iter2, _Out>;
struct __merge_fn
{
inline constexpr __includes_fn includes{};
template<typename _Iter1, typename _Iter2, typename _Out>
- using set_union_result = binary_transform_result<_Iter1, _Iter2, _Out>;
+ using set_union_result = in_in_out_result<_Iter1, _Iter2, _Out>;
struct __set_union_fn
{
inline constexpr __set_union_fn set_union{};
template<typename _Iter1, typename _Iter2, typename _Out>
- using set_intersection_result
- = binary_transform_result<_Iter1, _Iter2, _Out>;
+ using set_intersection_result = in_in_out_result<_Iter1, _Iter2, _Out>;
struct __set_intersection_fn
{
inline constexpr __set_intersection_fn set_intersection{};
template<typename _Iter, typename _Out>
- using set_difference_result = copy_result<_Iter, _Out>;
+ using set_difference_result = in_out_result<_Iter, _Out>;
struct __set_difference_fn
{
template<typename _Iter1, typename _Iter2, typename _Out>
using set_symmetric_difference_result
- = binary_transform_result<_Iter1, _Iter2, _Out>;
+ = in_in_out_result<_Iter1, _Iter2, _Out>;
struct __set_symmetric_difference_fn
{
inline constexpr __clamp_fn clamp{};
template<typename _Tp>
- struct minmax_result
+ struct min_max_result
{
[[no_unique_address]] _Tp min;
[[no_unique_address]] _Tp max;
template<typename _Tp2>
requires convertible_to<const _Tp&, _Tp2>
- operator minmax_result<_Tp2>() const &
+ constexpr
+ operator min_max_result<_Tp2>() const &
{ return {min, max}; }
template<typename _Tp2>
requires convertible_to<_Tp, _Tp2>
- operator minmax_result<_Tp2>() &&
+ constexpr
+ operator min_max_result<_Tp2>() &&
{ return {std::move(min), std::move(max)}; }
};
+ template<typename _Tp>
+ using minmax_result = min_max_result<_Tp>;
+
struct __minmax_fn
{
template<typename _Tp, typename _Proj = identity,
inline constexpr __max_element_fn max_element{};
template<typename _Iter>
- using minmax_element_result = minmax_result<_Iter>;
+ using minmax_element_result = min_max_result<_Iter>;
struct __minmax_element_fn
{
inline constexpr __lexicographical_compare_fn lexicographical_compare;
template<typename _Iter>
- struct next_permutation_result
+ struct in_found_result
{
+ [[no_unique_address]] _Iter in;
bool found;
- _Iter in;
+
+ template<typename _Iter2>
+ requires convertible_to<const _Iter&, _Iter2>
+ constexpr
+ operator in_found_result<_Iter2>() const &
+ { return {in, found}; }
+
+ template<typename _Iter2>
+ requires convertible_to<_Iter, _Iter2>
+ constexpr
+ operator in_found_result<_Iter2>() &&
+ { return {std::move(in), found}; }
};
+ template<typename _Iter>
+ using next_permutation_result = in_found_result<_Iter>;
+
struct __next_permutation_fn
{
template<bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent,
_Comp __comp = {}, _Proj __proj = {}) const
{
if (__first == __last)
- return {false, std::move(__first)};
+ return {std::move(__first), false};
auto __i = __first;
++__i;
if (__i == __last)
- return {false, std::move(__i)};
+ return {std::move(__i), false};
auto __lasti = ranges::next(__first, __last);
__i = __lasti;
;
ranges::iter_swap(__i, __j);
ranges::reverse(__ii, __last);
- return {true, std::move(__lasti)};
+ return {std::move(__lasti), true};
}
if (__i == __first)
{
ranges::reverse(__first, __last);
- return {false, std::move(__lasti)};
+ return {std::move(__lasti), false};
}
}
}
inline constexpr __next_permutation_fn next_permutation{};
template<typename _Iter>
- using prev_permutation_result = next_permutation_result<_Iter>;
+ using prev_permutation_result = in_found_result<_Iter>;
struct __prev_permutation_fn
{
_Comp __comp = {}, _Proj __proj = {}) const
{
if (__first == __last)
- return {false, std::move(__first)};
+ return {std::move(__first), false};
auto __i = __first;
++__i;
if (__i == __last)
- return {false, std::move(__i)};
+ return {std::move(__i), false};
auto __lasti = ranges::next(__first, __last);
__i = __lasti;
;
ranges::iter_swap(__i, __j);
ranges::reverse(__ii, __last);
- return {true, std::move(__lasti)};
+ return {std::move(__lasti), true};
}
if (__i == __first)
{
ranges::reverse(__first, __last);
- return {false, std::move(__lasti)};
+ return {std::move(__lasti), false};
}
}
}