std::default_accessor(3)
πΈ 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_accessorelement_typeβElementTypereferenceβ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)
- Default constructs a
default_accessor. Iconic, effortless, no notes. π - Constructs a
default_accessorfromdefault_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 ifstd::is_convertible_v<OtherElementType(*)[], element_type(*)[]>istrue. 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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms