A user-defined submdspan_mapping can return different mappings for the same kind of slice
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the [mdspan.sub.sub] wording cited in the issue, especially paragraphs 5.2 and 5.3, and compare its requirements for submdspan_mapping with submdspan_extents and the index-pair-like definition. Check how P2769R3 affects that definition. Done means determining whether the wording needs clarification about mappings returned for different slice types and identifying the required standard change.
Written by the indexing model from the issue text.
Description
The issue
A user-defined submdspan_mapping return different mappings for the same kind of slice. "Same kind of slice" means, for example, two different types that both model index-pair-like<index_type>.
This matters more given P2769R3 (get_element customization point object), which extends the definition of index-pair-like to include "anything for which get_element works." However, even the current definition of index-pair-like includes different Standard class templates, such as pair, tuple, array, and even complex. The following example shows a custom layout whose submdspan_mapping function returns a different layout mapping type, depending on whether the first slice is std::pair or some other index-pair-like type.
template<class T>
constexpr bool is_std_pair_v(T&&)
template<class First, class Second>
constexpr bool is_std_pair_v<std::pair<First, Second>> = true;
class custom_layout_1 {
template<class Extents>
class mapping { /* ... */ };
};
class custom_layout_2 {
template<class Extents>
class mapping { /* ... */ };
};
class custom_layout_3 {
template<class Extents>
class mapping {
// ...
template<class... SliceSpecifiers>
friend constexpr auto submdspan_mapping(
const mapping& src, SliceSpecifiers... slices) {
using return_type = std::conditional_t<
is_std_pair_v<std::remove_cvref_t<SliceSpecifiers...[0]>>,
typename custom_layout_1::template mapping<Extents>;
typename custom_layout_2::template mapping<Extents>
>;
return return_type{submdspan_extents(src.extents(), slices...)};
}
};
};
Is this really a problem?
submdspan's wording (specifically, [mdspan.sub.sub] 5.2 and 5.3) implicitly describes the behavior of submdspan_mapping. It doesn't specify the return type of submdspan_mapping (other than to say it's a layout mapping with the same extents as submdspan_extents would have produced, given the input extents and slice specifiers). However, it does spell out the result mapping's extents() and the behavior of its operator(). The effect is that the result of submdspan views the expected subset of elements of the input mdspan, regardless of the type of the result's layout mapping.
- Dominant language
- HTML
- Stars
- 29
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ORNL/cpp-proposals-pub
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
ORNL/cpp-proposals-pub#394 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
ORNL/cpp-proposals-pub#393 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ORNL/cpp-proposals-pub#297 ·
-
P3242: LWG ReviewOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ORNL/cpp-proposals-pub#484 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ORNL/cpp-proposals-pub#483 · 2 comments ·
All issues in ORNL/cpp-proposals-pub
Similar issues
-
compiler-rt:asan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
llvm/llvm-project#242921 ·
Maintainers usually reply within 1 day
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the modulePossibly taken @MalithaPrabhashana claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
jaseci-labs/jac#10756 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
area:interp bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
yidika-lab/yidika#80 ·
Maintainers usually reply within 1 day