CARVIEW |
Select Language
HTTP/2 200
date: Mon, 21 Jul 2025 15:26:04 GMT
content-type: text/html; charset=utf-8
cache-control: max-age=0, private, must-revalidate
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
link: ; rel=preload; as=fetch; crossorigin=use-credentials
referrer-policy: no-referrer-when-downgrade
server-timing: issue_layout-fragment;desc="issue_layout fragment";dur=233.30522,issue_conversation_content-fragment;desc="issue_conversation_content fragment";dur=437.115478,issue_conversation_sidebar-fragment;desc="issue_conversation_sidebar fragment";dur=42.437371,nginx;desc="NGINX";dur=1.514738,glb;desc="GLB";dur=96.382728
strict-transport-security: max-age=31536000; includeSubdomains; preload
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With, Accept,Accept-Encoding, Accept, X-Requested-With
x-content-type-options: nosniff
x-frame-options: deny
x-voltron-version: fd8fbbc
x-xss-protection: 0
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=AAXS%2FxkYkf9fpQ1bHHJAQ3zj%2FeT4QAcEM%2FWjr8O%2B9NWC44XvNCKYF%2BG89vIpFhitsQNtr10OApMt1vgLm1Y0r62wziMmp%2BezSpDOBC7FQ4wwjsKRmRPBp5nH5WfzwJw8QkJerUt61BgSbEOlyRpcteeUtCo55G%2FIBJEzE%2FejWUsJFG%2F5vfePjh8oxrFahD%2FpJ6Qy642LPQg8tkQU%2FagVuwBHXO2m%2BG%2FrdaYj2vE5ZqwfGSsgFwGetDjpIFitacmfx52ORYsJhB4UIpZTn1hykA%3D%3D--RnhZq9G8IxcKePKK--QvrmK57u67nl3ttdPBbY%2BA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1942163599.1753111564; Path=/; Domain=github.com; Expires=Tue, 21 Jul 2026 15:26:04 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Tue, 21 Jul 2026 15:26:04 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: DADC:1222CF:52960:6046D:687E5C0C
Return type of sorter adapters · Issue #134 · Morwenn/cpp-sort · GitHub

No one assignedNo projectsNo milestoneNone yetNo branches or pull requests
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Labels
Description
At first, sorter adapters were mostly designed to return the value returned by the wrapped sorters. However, with time some problems appeared with that design:
- Some adapters such as
counting_adapter
return a result. Currently it simply discards any value returned by the wrapped sorter and there is no way to get both values. This might become even more of a problem when using sorter adapters on measures of presortedness, or with sorting algorithms returning the end iterator as in the Ranges TS. - Handling both sorters that return
void
and sorters that return a value is quite tricky when the adapter needs to perform operations after thereturn
: returning the result of avoid
function is ok, but because of the lack of regularvoid
in the language it's impossible to generically store the result to return it later. The easiest solution is still to execute the code that comes after the call to the sorter in a lambda passed to ascope_exit
thingy (also hard to do prior to C++17 andstd::uncaught_exceptions
). - Some adapters are not suited to actually return a useful result: for example
verge_adapter
is only useful to make algorithms take advantage of big runs in the collection. However adapting a measure of presortedness with it wouldn't make sense and there is no obvious way to produce the result once adapted, soverge_adapter
is an example of an adapter that shouldn't forward the result of the underlying algorithm.
Now the first point is the most problematic one and the one for which there is no obvious solution. The possible solutions are as follows:
- Keeping the status quo: adapters either return a value they computed or the value of the wrapped sorter if they don't return a value of their own.
- Wrapping the values in a
std::pair
where one of the values is the one returned from the sorter and the other one is the one computed by the adapter. It becomes a usability problem if the nesting of adapters is too deep and I'd like a more scalable solution. - Wrapping the values in a
std::tuple
that is flattened through the adapter levels sounds like retrieving the exact result is hard. I would rather see a solution with tagged tuples which feels slightly more scalable: instead of simply returning an end iterator, a sorter could returnApparently LEWG is willing to drop the whole tag mechanism, so this solution would require to reinvent the whole mechanism, which I'm not really willing to do...tagged_tuple<tag::out(Iterator)>
and flattening thetagged_tuple
through adapters could be a bit safer. To keep the usability we would probably need some kind of tagged single-value container which implicitly converts to the wrapped type.
To be honest I'm still not convinced by any of the solutions, hence this issue. Any somewhat sane idea to make that both usable and scalable is welcome.
A first use case that should always be considered to decide whether it makes for an adapter to return the result of the underlying sorter is: can it be used on a measure of presortedness? If it can it probably makes sense to forward the result of the adapted sorter, otherwise I don't know.
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
Issue actions
You can’t perform that action at this time.