std::default_accessor(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

std::default_accessor β€” bestie, this is the default accessor, the fallback queen of <mdspan> πŸ’… (and yes, this page lives in the C++ Standard Library manual, section 3, iykyk)


✨ Synopsis ✨

Okay so picture this: it's defined in the header <mdspan>, right, and it looks like this:

template< class ElementType >  (since C++23)
class default_accessor;

The std::default_accessor class template is literally the default AccessorPolicy that std::mdspan uses when you don't hand it a user-specified accessor policy of your own. It's the "no thoughts, just vibes" of accessor policies, and honestly? It ate. 🫢

Every single specialization of default_accessor models semiregular and is TriviallyCopyable. Periodt. ✨


πŸ¦‹ Template parameters πŸ¦‹

  • ElementType β€” the element type, bestie. It shall be a complete object type that is neither an abstract class type nor an array type. Otherwise? The program is ill-formed. πŸ’€ Like, not "oopsie" ill-formed, we're talking hard no. Respect the rules.

πŸŽ€ Member types πŸŽ€

Here's the whole cast, main character energy only:

  • offset_policy β€” default_accessor
  • element_type β€” ElementType
  • reference β€” ElementType&
  • data_handle_type β€” ElementType*

πŸ’œ Member functions πŸ’œ

  • constructor β€” constructs a default_accessor (public member function)
  • access β€” returns the *n*th element provided by arguments (public member function)
  • offset β€” returns a data handle that has an offset provided by arguments (public member function)

🌈 std::default_accessor::default_accessor

Behold, the constructors:

constexpr default_accessor() noexcept = default;       (1)

template< class OtherElementType >
constexpr default_accessor( default_accessor<OtherElementType> ) noexcept {}   (2)
  1. Default constructs a default_accessor. Iconic, effortless, no notes. πŸ’…
  2. Constructs a default_accessor from default_accessor<OtherElementType>. The constructor has no visible effect β€” literally does nothing visible, it's giving "showed up, served looks, said nothing" 😭. This overload participates in overload resolution only if std::is_convertible_v<OtherElementType(*)[], element_type(*)[]> is true. That's the whole vibe check, no cap.

πŸ’– std::default_accessor::access

constexpr reference access( data_handle_type p, std::size_t i ) const noexcept;

Equivalent to return p[i];. That's it. That's the function. Simple, clean, slays. ✨

πŸ“ std::default_accessor::offset

constexpr data_handle_type offset( data_handle_type p, std::size_t i ) const noexcept;

Equivalent to return p + i;. Pointer math but make it fashion. 🧚


πŸ™ˆ Example

This section is incomplete.

Reason: no example 😭

It's giving "left on read". The example section is literally Todo no example β€” big mood, honestly.

Category:

  • Todo no example

And that's the tea, bestie πŸ«ΆπŸ’– β€” this page came to you courtesy of cppreference.com, dated 2024.06.10, on the std::default_accessor(3) page of the C++ Standard Library manual. Go forth and accessor, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from