Skip to content

Commit

Permalink
Merge pull request #237 from nmm0/padded-layout
Browse files Browse the repository at this point in the history
Padded layout
  • Loading branch information
crtrott authored Oct 20, 2023
2 parents 33a0b93 + 91633d1 commit ed5f6f6
Show file tree
Hide file tree
Showing 8 changed files with 1,935 additions and 0 deletions.
31 changes: 31 additions & 0 deletions include/experimental/__p0009_bits/layout_left.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "macros.hpp"
#include "trait_backports.hpp"
#include "extents.hpp"
#include "../__p2642_bits/layout_padded_fwd.hpp"

namespace MDSPAN_IMPL_STANDARD_NAMESPACE {

Expand Down Expand Up @@ -108,6 +109,36 @@ class layout_left::mapping {
*/
}

#if MDSPAN_HAS_CXX_17
/**
* Converting constructor from `layout_left_padded::mapping`.
*
* This overload participates in overload resolution only if _Mapping is a layout_left_padded mapping and
* extents_type is constructible from _Mapping::extents_type.
*
* \note There is currently a difference from p2642r2, where this function is specified as taking
* `layout_left_padded< padding_value >::mapping< Extents>`. However, this makes `padding_value` non-deducible.
*/
MDSPAN_TEMPLATE_REQUIRES(
class _Mapping,
/* requires */ (
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_left_padded_mapping<_Mapping>::value
&& std::is_constructible_v<extents_type, typename _Mapping::extents_type>
)
)
MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<typename _Mapping::extents_type, extents_type>))
mapping(const _Mapping& __other) noexcept
: __extents(__other.extents())
{
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::
check_padded_layout_converting_constructor_mandates<extents_type,
_Mapping>();
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::
check_padded_layout_converting_constructor_preconditions<
extents_type>(__other);
}
#endif

MDSPAN_TEMPLATE_REQUIRES(
class OtherExtents,
/* requires */ (
Expand Down
29 changes: 29 additions & 0 deletions include/experimental/__p0009_bits/layout_right.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "extents.hpp"
#include <stdexcept>
#include "layout_stride.hpp"
#include "../__p2642_bits/layout_padded_fwd.hpp"

namespace MDSPAN_IMPL_STANDARD_NAMESPACE {

Expand Down Expand Up @@ -113,6 +114,34 @@ class layout_right::mapping {
*/
}

/**
* Converting constructor from `layout_right_padded::mapping`.
*
* This overload participates in overload resolution only if _Mapping is a layout_right_padded mapping and
* extents_type is constructible from _Mapping::extents_type.
*
* \note There is currently a difference from p2642r2, where this function is specified as taking
* `layout_right_padded< padding_value >::mapping< Extents>`. However, this makes `padding_value` non-deducible.
*/
#if MDSPAN_HAS_CXX_17
MDSPAN_TEMPLATE_REQUIRES(
class _Mapping,
/* requires */ (
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::is_layout_right_padded_mapping<_Mapping>::value
&& std::is_constructible_v<extents_type, typename _Mapping::extents_type>))
MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<typename _Mapping::extents_type, extents_type>))
mapping(const _Mapping &__other) noexcept
: __extents(__other.extents())
{
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::
check_padded_layout_converting_constructor_mandates<extents_type,
_Mapping>();
MDSPAN_IMPL_PROPOSED_NAMESPACE::detail::
check_padded_layout_converting_constructor_preconditions<
extents_type>(__other);
}
#endif

MDSPAN_TEMPLATE_REQUIRES(
class OtherExtents,
/* requires */ (
Expand Down
Loading

0 comments on commit ed5f6f6

Please sign in to comment.