ORNL / ORNL/cpp-proposals-pub

P1684: to_mdspan can't default to default_accessor with arbitrary container type, because type aliases are missing

Open
#336 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
29
Forks
26
PR merge metrics
No merged PRs in 30d

Description

This is a follow-on to #330. @crtrott @dalg24 @nliber

mdarray defines to_mdspan member functions that return an mdspan viewing the mdarray's elements. The functions are templated on the accessor type, and users can supply the accessor instance. Here is their declaration.

  template<class OtherAccessorType = default_accessor<element_type>>
    auto to_mdspan(const OtherAccessorType& a = 
                     default_accessor<element_type>()) const noexcept;
  template<class OtherAccessorType = default_accessor<const element_type>>
    auto to_mdspan(const OtherAccessorType& a = 
                     default_accessor<const element_type>()) const noexcept;

The immediate problem with these functions is that their accessor type always defaults to default_accessor. That won't work if the container_type lacks reference and pointer type aliases. (container_type must be a contiguous container, so these type aliases, if they exist, would most sensibly spell element_type& resp. element_type*.) Do contiguous containers need to have these type aliases?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the to_mdspan declarations in the issue and read the linked follow-on issue #330 for context. Determine how arbitrary contiguous container types should supply the needed accessor information and what API change would resolve the defaulting problem; the issue is complete when that design question is answered and the declarations can support the intended container types.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.