Skip to content

Commit 86a4572

Browse files
committed
Rename make_projection_compare in projection_compare
1 parent 7edb3ca commit 86a4572

File tree

9 files changed

+72
-72
lines changed

9 files changed

+72
-72
lines changed

docs/Comparator-adapters.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ constexpr auto base() const
4444
`cppsort::flip` takes a *Callable* `f` of type `F` and returns an instance of `flip_t<std::decay_t<F>>` except in the following cases:
4545
* When given a `flip_t<F>`, it returns a `F`.
4646
* When given a `not_fn_t<flip_t<F>>`, it returns a `not_fn_t<F>`.
47-
* When given a `projection_compare` it returns `make_projection_compare(flip(f.comparison()), f.projection())`.
47+
* When given a `projection_compare_t` it returns `projection_compare(flip(f.comparison()), f.projection())`.
4848
4949
`flip_t<F>` is [*transparent*][transparent-func] when `F` is *transparent*.
5050
@@ -82,7 +82,7 @@ constexpr auto base() const
8282
`cppsort::not_fn` takes a *Callable* `f` of type `F` and returns an instance of `not_fn_t<std::decay_t<F>>` except in the following cases:
8383
* When given a `not_fn_t<F>`, it returns a `F`.
8484
* When given a `flip_t<not_fn_t<F>>`, it returns a `flip_t<F>`.
85-
* When given a `projection_compare` it returns `make_projection_compare(not_fn(f.comparison()), f.projection())`.
85+
* When given a `projection_compare_t` it returns `projection_compare(not_fn(f.comparison()), f.projection())`.
8686
8787
`not_fn_t<F>` is [*transparent*][transparent-func] when `F` is *transparent*.
8888
@@ -94,24 +94,24 @@ constexpr auto base() const
9494
#include <cpp-sort/comparators/projection_compare.h>
9595
```
9696

97-
The class template `projection_compare` can be used to embed a comparison and a projection in a single comparison object, allowing to provide projection support to algorithms that only support comparisons, such as standard library algorithms prior to C++20. Both the passed comparison and projection functions can be [*Callable*][callable].
97+
The class template `projection_compare_t` can be used to embed a comparison and a projection in a single comparison object, allowing to provide projection support to algorithms that only support comparisons, such as standard library algorithms prior to C++20. Both the passed comparison and projection functions can be [*Callable*][callable].
9898

99-
It is accompanied by a `make_projection_compare` function template to avoid having to pass the template parameters by hand.
99+
It is accompanied by a `projection_compare` function template to avoid having to pass the template parameters by hand, and to perform a few optimizations.
100100

101101
**Example:**
102102

103103
```cpp
104104
// Sort a family from older to younger member
105105
std::vector<Person> family = { /* ... */ };
106-
std::sort(family.begin(), family.end(), cppsort::make_projection_compare(std::greater{}, &Person::age));
106+
std::sort(family.begin(), family.end(), cppsort::projection_compare(std::greater{}, &Person::age));
107107
```
108108
109-
`projection_compare<C, P>` has the following member functions:
109+
`projection_compare_t<C, P>` has the following member functions:
110110
111111
```cpp
112112
// Construction
113-
projection_compare() = default;
114-
projection_compare(C comp, P proj);
113+
projection_compare_t() = default;
114+
projection_compare_t(C comp, P proj);
115115
116116
// Call
117117
template<typename T1, typename T2>
@@ -132,12 +132,12 @@ constexpr auto projection() const
132132
-> P;
133133
```
134134

135-
`cppsort::make_projection_compare` takes two *Callable* of types `C` and `P` and returns an instance of `projection_compare<std::decay_t<C>, std::decay_t<P>>` except in the following cases:
135+
`cppsort::projection_compare` takes two *Callable* types `C` and `P` and returns an instance of `projection_compare_t<std::decay_t<C>, std::decay_t<P>>` except in the following cases:
136136
* When `std::decay_t<P>` is of type [`utility::identity`][utility-identity] or [`std::identity`][std-identity], it returns `C` directly.
137137

138-
`projection_compare` is [*transparent*][transparent-func] when the passed comparison and projection are both *transparent*.
138+
`projection_compare_t` is [*transparent*][transparent-func] when the passed comparison and projection are both *transparent*.
139139

140-
`projection_compare` is considered [branchless][branchless-traits] when the projection it wraps is considered branchless and the comparison it wraps is considered branchless when called with the result of the projection.
140+
`projection_compare_t` is considered [branchless][branchless-traits] when the projection it wraps is considered branchless and the comparison it wraps is considered branchless when called with the result of the projection.
141141

142142
*New in version 1.9.0*
143143

include/cpp-sort/adapters/container_aware_adapter.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,18 @@ namespace cppsort
221221
detail::can_comparison_sort<
222222
Sorter,
223223
Iterable,
224-
projection_compare<std::less<>, Projection>
224+
projection_compare_t<std::less<>, Projection>
225225
>::value,
226226
conditional_t<
227227
Stability,
228228
std::false_type,
229229
decltype(detail::adl_despair{}(this->get(), iterable,
230-
make_projection_compare(std::less{}, std::move(projection))))
230+
projection_compare(std::less{}, std::move(projection))))
231231
>
232232
>
233233
{
234234
return detail::adl_despair{}(this->get(), iterable,
235-
make_projection_compare(std::less{}, std::move(projection)));
235+
projection_compare(std::less{}, std::move(projection)));
236236
}
237237

238238
template<
@@ -248,7 +248,7 @@ namespace cppsort
248248
not detail::can_comparison_sort<
249249
Sorter,
250250
Iterable,
251-
projection_compare<std::less<>, Projection>
251+
projection_compare_t<std::less<>, Projection>
252252
>::value,
253253
conditional_t<
254254
Stability,
@@ -293,18 +293,18 @@ namespace cppsort
293293
detail::can_comparison_sort<
294294
Sorter,
295295
Iterable,
296-
projection_compare<Compare, Projection>
296+
projection_compare_t<Compare, Projection>
297297
>::value,
298298
conditional_t<
299299
Stability,
300300
std::false_type,
301301
decltype(detail::adl_despair{}(this->get(), iterable,
302-
make_projection_compare(std::move(compare), std::move(projection))))
302+
projection_compare(std::move(compare), std::move(projection))))
303303
>
304304
>
305305
{
306306
return detail::adl_despair{}(this->get(), iterable,
307-
make_projection_compare(std::move(compare), std::move(projection)));
307+
projection_compare(std::move(compare), std::move(projection)));
308308
}
309309

310310
template<
@@ -319,7 +319,7 @@ namespace cppsort
319319
not detail::can_comparison_sort<
320320
Sorter,
321321
Iterable,
322-
projection_compare<Compare, Projection>
322+
projection_compare_t<Compare, Projection>
323323
>::value,
324324
conditional_t<
325325
Stability,

include/cpp-sort/comparators/flip.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace cppsort
1919
template<typename F>
2020
struct not_fn_t;
2121
template<typename F1, typename F2>
22-
class projection_compare;
22+
class projection_compare_t;
2323

2424
////////////////////////////////////////////////////////////
2525
// flip_t
@@ -153,13 +153,13 @@ namespace cppsort
153153
};
154154

155155
template<typename F1, typename F2>
156-
struct flip_impl<projection_compare<F1, F2>>
156+
struct flip_impl<projection_compare_t<F1, F2>>
157157
{
158-
using type = projection_compare<
158+
using type = projection_compare_t<
159159
typename detail::flip_impl<F1>::type, F2
160160
>;
161161

162-
static constexpr auto construct(const projection_compare<F1, F2>& func)
162+
static constexpr auto construct(const projection_compare_t<F1, F2>& func)
163163
-> type
164164
{
165165
return type(

include/cpp-sort/comparators/not_fn.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace cppsort
1818
template<typename F>
1919
struct flip_t;
2020
template<typename F1, typename F2>
21-
class projection_compare;
21+
class projection_compare_t;
2222

2323
////////////////////////////////////////////////////////////
2424
// not_fn_t
@@ -152,13 +152,13 @@ namespace cppsort
152152
};
153153

154154
template<typename F1, typename F2>
155-
struct not_fn_impl<projection_compare<F1, F2>>
155+
struct not_fn_impl<projection_compare_t<F1, F2>>
156156
{
157-
using type = projection_compare<
157+
using type = projection_compare_t<
158158
typename detail::not_fn_impl<F1>::type, F2
159159
>;
160160

161-
static constexpr auto construct(const projection_compare<F1, F2>& func)
161+
static constexpr auto construct(const projection_compare_t<F1, F2>& func)
162162
-> type
163163
{
164164
return type(

include/cpp-sort/comparators/projection_compare.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace cppsort
2020
{
2121
template<typename Compare, typename Projection>
22-
class projection_compare:
22+
class projection_compare_t:
2323
public detail::raw_check_is_transparent<Compare, Projection>
2424
{
2525
private:
@@ -28,9 +28,9 @@ namespace cppsort
2828

2929
public:
3030

31-
projection_compare() = default;
31+
projection_compare_t() = default;
3232

33-
projection_compare(Compare compare, Projection projection):
33+
projection_compare_t(Compare compare, Projection projection):
3434
data(std::move(compare), std::move(projection))
3535
{}
3636

@@ -117,14 +117,14 @@ namespace cppsort
117117
};
118118

119119
////////////////////////////////////////////////////////////
120-
// Helper for projection_compare construction
120+
// Helper for projection_compare_t construction
121121

122122
namespace detail
123123
{
124124
template<typename Compare, typename Projection>
125125
struct proj_comp_impl
126126
{
127-
using type = projection_compare<Compare, Projection>;
127+
using type = projection_compare_t<Compare, Projection>;
128128

129129
template<typename C, typename P>
130130
static constexpr auto construct(C&& comp, P&& proj)
@@ -174,10 +174,10 @@ namespace cppsort
174174
}
175175

176176
////////////////////////////////////////////////////////////
177-
// make_projection_compare
177+
// projection_compare
178178

179179
template<typename Compare, typename Projection>
180-
constexpr auto make_projection_compare(Compare&& compare, Projection&& projection)
180+
constexpr auto projection_compare(Compare&& compare, Projection&& projection)
181181
-> typename detail::proj_comp_impl<std::decay_t<Compare>, std::decay_t<Projection>>::type
182182
{
183183
return detail::proj_comp_impl<std::decay_t<Compare>, std::decay_t<Projection>>::construct(
@@ -188,7 +188,7 @@ namespace cppsort
188188
namespace utility
189189
{
190190
template<typename Compare, typename Projection, typename T>
191-
struct is_probably_branchless_comparison<projection_compare<Compare, Projection>, T>:
191+
struct is_probably_branchless_comparison<projection_compare_t<Compare, Projection>, T>:
192192
std::conjunction<
193193
is_probably_branchless_projection<Projection, T>,
194194
is_probably_branchless_comparison<

include/cpp-sort/detail/container_aware/mel_sort.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ namespace cppsort
8080
if (lists.size() % 2 != 0) {
8181
auto last_it = std::prev(lists.end());
8282
auto last_1_it = std::prev(last_it);
83-
last_1_it->merge(*last_it, make_projection_compare(comp, proj));
83+
last_1_it->merge(*last_it, projection_compare(comp, proj));
8484
lists.pop_back();
8585
}
8686

8787
auto first_it = lists.begin();
8888
auto half_it = first_it + lists.size() / 2;
8989
while (half_it != lists.end()) {
90-
first_it->merge(*half_it, make_projection_compare(comp, proj));
90+
first_it->merge(*half_it, projection_compare(comp, proj));
9191
++first_it;
9292
++half_it;
9393
}
@@ -172,14 +172,14 @@ namespace cppsort
172172
if (lists.size() % 2 != 0) {
173173
auto last_it = std::prev(lists.end());
174174
auto last_1_it = std::prev(last_it);
175-
last_1_it->list.merge(last_it->list, make_projection_compare(comp, proj));
175+
last_1_it->list.merge(last_it->list, projection_compare(comp, proj));
176176
lists.pop_back();
177177
}
178178

179179
auto first_it = lists.begin();
180180
auto half_it = first_it + lists.size() / 2;
181181
while (half_it != lists.end()) {
182-
first_it->list.merge(half_it->list, make_projection_compare(comp, proj));
182+
first_it->list.merge(half_it->list, projection_compare(comp, proj));
183183
++first_it;
184184
++half_it;
185185
}

include/cpp-sort/detail/container_aware/merge_sort.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ namespace cppsort
4242
// Recursively sort, then merge
4343
list_merge_sort(left, compare, projection);
4444
list_merge_sort(collection, compare, projection);
45-
collection.merge(std::move(left), make_projection_compare(std::move(compare),
46-
std::move(projection)));
45+
collection.merge(std::move(left), projection_compare(std::move(compare),
46+
std::move(projection)));
4747
}
4848

4949
template<typename Compare, typename Projection,
@@ -63,8 +63,8 @@ namespace cppsort
6363
// Recursively sort, then merge
6464
flist_merge_sort(left, size / 2, compare, projection);
6565
flist_merge_sort(collection, size - size / 2, compare, projection);
66-
collection.merge(std::move(left), make_projection_compare(std::move(compare),
67-
std::move(projection)));
66+
collection.merge(std::move(left), projection_compare(std::move(compare),
67+
std::move(projection)));
6868
}
6969
}
7070

0 commit comments

Comments
 (0)