boostorg / boostorg/hana

hana::sort seems like it should work with hana::experimental::types but does't

Open
#495 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.9k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

While it might seem odd considering types don't have a lexicographical order where integral values would, with a predicate, the types might be sorted by some arbitrary manner.

This is currently not possible because `types` is missing a `Sequence` specialization, but even if it did have it, it would choke in `sort.hpp` though I'm not informed enough to understand why.

Not sure if this is helpful, but here's an example error when attempting to use a hacked up version where `Sequence` has been set to true for `types`

```
boost/hana/sort.hpp:65:36: error: no matching function for call to object of type ... >::(lambda at ...)'
using apply = decltype(std::declval()(
^~~~~~~~~~~~~~~~~~~~
boost/hana/sort.hpp:118:51: note: in instantiation of template type alias 'apply' requested here
Pred, T, (bool)Pred::template apply::value,
^
boost/hana/sort.hpp:128:35: note: in instantiation of template class 'boost::hana::detail::insertion_sort_impl<...
```

Contributor guide

Open the contributing guide

Research direction

Start by reading the Sequence treatment of hana::experimental::types and the predicate handling in sort.hpp, then reproduce the reported compiler error with the example from the issue. Trace why insertion_sort_impl cannot invoke the predicate for types. Done means the requested sort use case is supported with a predicate and covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.