Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented changes from P1716 #310

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/adjacent_find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
STL2_OPEN_NAMESPACE {
struct __adjacent_find_fn : private __niebloid {
template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
IndirectRelation<projected<I, Proj>> Pred = equal_to>
IndirectBinaryPredicate<projected<I, Proj>, projected<I, Proj>> Pred = equal_to>
constexpr I
operator()(I first, S last, Pred pred = {}, Proj proj = {}) const {
if (first == last) {
Expand All @@ -42,7 +42,7 @@ STL2_OPEN_NAMESPACE {
}

template<ForwardRange R, class Proj = identity,
IndirectRelation<projected<iterator_t<R>, Proj>> Pred = equal_to>
IndirectBinaryPredicate<projected<iterator_t<R>, Proj>, projected<iterator_t<R>, Proj>> Pred = equal_to>
constexpr safe_iterator_t<R>
operator()(R&& r, Pred pred = {}, Proj proj = {}) const {
return (*this)(begin(r), end(r), __stl2::ref(pred),
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
STL2_OPEN_NAMESPACE {
struct __count_fn : private __niebloid {
template<InputIterator I, Sentinel<I> S, class T, class Proj = identity>
requires IndirectRelation<equal_to, projected<I, Proj>, const T*>
requires IndirectBinaryPredicate<equal_to, projected<I, Proj>, const T*>
constexpr iter_difference_t<I>
operator()(I first, S last, const T& value, Proj proj = {}) const {
iter_difference_t<I> n = 0;
Expand All @@ -34,7 +34,7 @@ STL2_OPEN_NAMESPACE {
}

template<InputRange R, class T, class Proj = identity>
requires IndirectRelation<equal_to, projected<iterator_t<R>, Proj>, const T*>
requires IndirectBinaryPredicate<equal_to, projected<iterator_t<R>, Proj>, const T*>
constexpr iter_difference_t<iterator_t<R>>
operator()(R&& r, const T& value, Proj proj = {}) const {
return (*this)(begin(r), end(r), value, __stl2::ref(proj));
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
STL2_OPEN_NAMESPACE {
struct __find_fn : private __niebloid {
template<InputIterator I, Sentinel<I> S, class T, class Proj = identity>
requires IndirectRelation<equal_to, projected<I, Proj>, const T*>
requires IndirectBinaryPredicate<equal_to, projected<I, Proj>, const T*>
constexpr I
operator()(I first, S last, const T& value, Proj proj = {}) const {
for (; first != last; ++first) {
Expand All @@ -33,7 +33,7 @@ STL2_OPEN_NAMESPACE {
}

template<InputRange R, class T, class Proj = identity>
requires IndirectRelation<equal_to, projected<iterator_t<R>, Proj>, const T*>
requires IndirectBinaryPredicate<equal_to, projected<iterator_t<R>, Proj>, const T*>
constexpr safe_iterator_t<R>
operator()(R&& r, const T& value, Proj proj = {}) const {
return (*this)(begin(r), end(r), value, __stl2::ref(proj));
Expand Down
14 changes: 8 additions & 6 deletions include/stl2/detail/algorithm/find_first_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
STL2_OPEN_NAMESPACE {
struct __find_first_of_fn : private __niebloid {
template<InputIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2,
class Proj1 = identity, class Proj2 = identity,
IndirectRelation<projected<I1, Proj1>, projected<I2, Proj2>> Pred = equal_to>
class Pred = equal_to,
class Proj1 = identity, class Proj2 = identity>
requires
IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
constexpr I1 operator()(I1 first1, S1 last1, I2 first2, S2 last2,
Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) const
{
Expand All @@ -40,10 +42,10 @@ STL2_OPEN_NAMESPACE {
}

template<InputRange R1, ForwardRange R2,
class Proj1 = identity, class Proj2 = identity,
IndirectRelation<
projected<iterator_t<R1>, Proj1>,
projected<iterator_t<R2>, Proj2>> Pred = equal_to>
class Pred = equal_to,
class Proj1 = identity, class Proj2 = identity>
requires
IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
constexpr safe_iterator_t<R1>
operator()(R1&& r1, R2&& r2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {}) const
Expand Down
12 changes: 5 additions & 7 deletions include/stl2/detail/algorithm/is_permutation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
STL2_OPEN_NAMESPACE {
struct __is_permutation_fn : private __niebloid {
template<ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2,
Sentinel<I2> S2, class Pred = equal_to, class Proj1 = identity,
class Proj2 = identity>
requires IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
Sentinel<I2> S2, class Proj1 = identity, class Proj2 = identity,
IndirectEquivalenceRelation<projected<I1, Proj1>, projected<I2, Proj2>> Pred = equal_to>
constexpr bool operator()(I1 first1, S1 last1, I2 first2, S2 last2,
Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) const
{
Expand Down Expand Up @@ -61,10 +60,9 @@ STL2_OPEN_NAMESPACE {
}
}

template<ForwardRange R1, ForwardRange R2, class Pred = equal_to,
class Proj1 = identity, class Proj2 = identity>
requires IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred,
Proj1, Proj2>
template<ForwardRange R1, ForwardRange R2,
class Proj1 = identity, class Proj2 = identity,
IndirectEquivalenceRelation<projected<iterator_t<R1>, Proj1>, projected<iterator_t<R2>, Proj2>> Pred = equal_to>
constexpr bool operator()(R1&& r1, R2&& r2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {}) const
{
Expand Down
13 changes: 7 additions & 6 deletions include/stl2/detail/algorithm/mismatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ STL2_OPEN_NAMESPACE {

struct __mismatch_fn : private __niebloid {
template<InputIterator I1, Sentinel<I1> S1, InputIterator I2,
Sentinel<I2> S2, class Proj1 = identity, class Proj2 = identity,
IndirectRelation<projected<I1, Proj1>,
projected<I2, Proj2>> Pred = equal_to>
Sentinel<I2> S2, class Pred = equal_to, class Proj1 = identity, class Proj2 = identity>
requires
IndirectlyComparable<I1, I2, Pred, Proj1, Proj2>
constexpr mismatch_result<I1, I2>
operator()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {}) const
Expand All @@ -47,9 +47,10 @@ STL2_OPEN_NAMESPACE {
}

template<InputRange R1, InputRange R2,
class Proj1 = identity, class Proj2 = identity,
IndirectRelation<projected<iterator_t<R1>, Proj1>,
projected<iterator_t<R2>, Proj2>> Pred = equal_to>
class Pred = equal_to,
class Proj1 = identity, class Proj2 = identity>
requires
IndirectlyComparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
constexpr mismatch_result<safe_iterator_t<R1>, safe_iterator_t<R2>>
operator()(R1&& r1, R2&& r2, Pred pred = {},
Proj1 proj1 = {}, Proj2 proj2 = {}) const
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/remove.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
STL2_OPEN_NAMESPACE {
struct __remove_fn : private __niebloid {
template<Permutable I, Sentinel<I> S, class T, class Proj = identity>
requires IndirectRelation<equal_to, projected<I, Proj>, const T*>
requires IndirectBinaryPredicate<equal_to, projected<I, Proj>, const T*>
constexpr I
operator()(I first, S last, const T& value, Proj proj = {}) const {
first = find(std::move(first), last, value, __stl2::ref(proj));
Expand All @@ -39,7 +39,7 @@ STL2_OPEN_NAMESPACE {

template<ForwardRange Rng, class T, class Proj = identity>
requires Permutable<iterator_t<Rng>> &&
IndirectRelation<equal_to, projected<iterator_t<Rng>, Proj>, const T*>
IndirectBinaryPredicate<equal_to, projected<iterator_t<Rng>, Proj>, const T*>
constexpr safe_iterator_t<Rng>
operator()(Rng&& rng, const T& value, Proj proj = {}) const {
return (*this)(begin(rng), end(rng), value, __stl2::ref(proj));
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/remove_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ STL2_OPEN_NAMESPACE {
template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O, class T,
class Proj = identity>
requires IndirectlyCopyable<I, O> &&
IndirectRelation<equal_to, projected<I, Proj>, const T*>
IndirectBinaryPredicate<equal_to, projected<I, Proj>, const T*>
constexpr remove_copy_result<I, O>
operator()(I first, S last, O result, const T& value, Proj proj = {}) const {
for (; first != last; ++first) {
Expand All @@ -42,7 +42,7 @@ STL2_OPEN_NAMESPACE {

template<InputRange R, WeaklyIncrementable O, class T, class Proj = identity>
requires IndirectlyCopyable<iterator_t<R>, O> &&
IndirectRelation<equal_to, projected<iterator_t<R>, Proj>, const T*>
IndirectBinaryPredicate<equal_to, projected<iterator_t<R>, Proj>, const T*>
constexpr remove_copy_result<safe_iterator_t<R>, O>
operator()(R&& r, O result, const T& value, Proj proj = {}) const {
return (*this)(begin(r), end(r), std::move(result), value, __stl2::ref(proj));
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/replace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ STL2_OPEN_NAMESPACE {
template<InputIterator I, Sentinel<I> S, class T1, class T2,
class Proj = identity>
requires Writable<I, const T2&> &&
IndirectRelation<equal_to, projected<I, Proj>, const T1*>
IndirectBinaryPredicate<equal_to, projected<I, Proj>, const T1*>
constexpr I operator()(I first, S last, const T1& old_value,
const T2& new_value, Proj proj = {}) const
{
Expand All @@ -37,7 +37,7 @@ STL2_OPEN_NAMESPACE {

template<InputRange R, class T1, class T2, class Proj = identity>
requires Writable<iterator_t<R>, const T2&> &&
IndirectRelation<equal_to, projected<iterator_t<R>, Proj>, const T1*>
IndirectBinaryPredicate<equal_to, projected<iterator_t<R>, Proj>, const T1*>
constexpr safe_iterator_t<R> operator()(R&& r, const T1& old_value,
const T2& new_value, Proj proj = {}) const
{
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/replace_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ STL2_OPEN_NAMESPACE {
template<InputIterator I, Sentinel<I> S, class T1, class T2,
OutputIterator<const T2&> O, class Proj = identity>
requires IndirectlyCopyable<I, O> &&
IndirectRelation<equal_to, projected<I, Proj>, const T1*>
IndirectBinaryPredicate<equal_to, projected<I, Proj>, const T1*>
constexpr replace_copy_result<I, O>
operator()(I first, S last, O result, const T1& old_value,
const T2& new_value, Proj proj = {}) const
Expand All @@ -46,7 +46,7 @@ STL2_OPEN_NAMESPACE {
template<InputRange R, class T1, class T2, OutputIterator<const T2&> O,
class Proj = identity>
requires IndirectlyCopyable<iterator_t<R>, O> &&
IndirectRelation<equal_to, projected<iterator_t<R>, Proj>, const T1*>
IndirectBinaryPredicate<equal_to, projected<iterator_t<R>, Proj>, const T1*>
constexpr replace_copy_result<safe_iterator_t<R>, O>
operator()(R&& r, O result, const T1& old_value, const T2& new_value,
Proj proj = {}) const
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/unique.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
STL2_OPEN_NAMESPACE {
struct __unique_fn : private __niebloid {
template<Permutable I, Sentinel<I> S, class Proj = identity,
IndirectRelation<projected<I, Proj>> Comp = equal_to>
IndirectEquivalenceRelation<projected<I, Proj>> Comp = equal_to>
constexpr I
operator()(I first, S last, Comp comp = {}, Proj proj = {}) const {
first = adjacent_find(std::move(first), last, __stl2::ref(comp),
Expand All @@ -41,7 +41,7 @@ STL2_OPEN_NAMESPACE {
}

template<ForwardRange R, class Proj = identity,
IndirectRelation<projected<iterator_t<R>, Proj>> Comp = equal_to>
IndirectEquivalenceRelation<projected<iterator_t<R>, Proj>> Comp = equal_to>
requires Permutable<iterator_t<R>>
constexpr safe_iterator_t<R>
operator()(R&& r, Comp comp = {}, Proj proj = {}) const {
Expand Down
4 changes: 2 additions & 2 deletions include/stl2/detail/algorithm/unique_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ STL2_OPEN_NAMESPACE {
struct __unique_copy_fn : private __niebloid {
template<InputIterator I, Sentinel<I> S, WeaklyIncrementable O,
class Proj = identity,
IndirectRelation<projected<I, Proj>> C = equal_to>
IndirectEquivalenceRelation<projected<I, Proj>> C = equal_to>
requires IndirectlyCopyable<I, O> &&
(ForwardIterator<I> || __unique_copy_helper<I, O> ||
IndirectlyCopyableStorable<I, O>)
Expand Down Expand Up @@ -82,7 +82,7 @@ STL2_OPEN_NAMESPACE {
}

template<InputRange R, WeaklyIncrementable O, class Proj = identity,
IndirectRelation<projected<iterator_t<R>, Proj>> C = equal_to>
IndirectEquivalenceRelation<projected<iterator_t<R>, Proj>> C = equal_to>
requires IndirectlyCopyable<iterator_t<R>, O> &&
(ForwardRange<R> || __unique_copy_helper<iterator_t<R>, O> ||
IndirectlyCopyableStorable<iterator_t<R>, O>)
Expand Down
25 changes: 18 additions & 7 deletions include/stl2/detail/concepts/callable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,26 @@ STL2_OPEN_NAMESPACE {
ext::IndirectPredicate<F, I>;

template<class F, class I1, class I2 = I1>
META_CONCEPT IndirectRelation =
META_CONCEPT IndirectBinaryPredicate =
Readable<I1> &&
Readable<I2> &&
CopyConstructible<F> &&
Relation<F&, iter_value_t<I1>&, iter_value_t<I2>&> &&
Relation<F&, iter_value_t<I1>&, iter_reference_t<I2>> &&
Relation<F&, iter_reference_t<I1>, iter_value_t<I2>&> &&
Relation<F&, iter_reference_t<I1>, iter_reference_t<I2>> &&
Relation<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;
Predicate<F&, iter_value_t<I1>&, iter_value_t<I2>&> &&
Predicate<F&, iter_value_t<I1>&, iter_reference_t<I2>> &&
Predicate<F&, iter_reference_t<I1>, iter_value_t<I2>&> &&
Predicate<F&, iter_reference_t<I1>, iter_reference_t<I2>> &&
Predicate<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;

template<class F, class I1, class I2 = I1>
META_CONCEPT IndirectEquivalenceRelation =
Readable<I1> &&
Readable<I2> &&
CopyConstructible<F> &&
EquivalenceRelation<F&, iter_value_t<I1>&, iter_value_t<I2>&> &&
EquivalenceRelation<F&, iter_value_t<I1>&, iter_reference_t<I2>> &&
EquivalenceRelation<F&, iter_reference_t<I1>, iter_value_t<I2>&> &&
EquivalenceRelation<F&, iter_reference_t<I1>, iter_reference_t<I2>> &&
EquivalenceRelation<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;

template<class F, class I1, class I2 = I1>
META_CONCEPT IndirectStrictWeakOrder =
Expand Down Expand Up @@ -160,7 +171,7 @@ STL2_OPEN_NAMESPACE {
template<class I1, class I2, class R = equal_to, class P1 = identity,
class P2 = identity>
META_CONCEPT IndirectlyComparable =
IndirectRelation<R, projected<I1, P1>, projected<I2, P2>>;
IndirectBinaryPredicate<R, projected<I1, P1>, projected<I2, P2>>;

////////////////////////////////////////////////////////////////////////////
// Permutable [alg.req.permutable]
Expand Down
6 changes: 6 additions & 0 deletions include/stl2/detail/concepts/function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ STL2_OPEN_NAMESPACE {
const std::remove_reference_t<T>&,
const std::remove_reference_t<U>&>>;

///////////////////////////////////////////////////////////////////////////
// EquivalenceRelation
//
template<class R, class T, class U>
META_CONCEPT EquivalenceRelation = Relation<R, T, U>;

///////////////////////////////////////////////////////////////////////////
// StrictWeakOrder [concepts.lib.callables.strictweakorder]
//
Expand Down