std::experi...::operator[](3)

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

πŸ’– NAME πŸ’–

std::experimental::shared_ptr::operator[] - std::experimental::shared_ptr::operator[] πŸ’…

Okay bestie, this is the std::experi...::operator[](3) page from the C++ Standard Libary manual β€” yes, β€œLibary” is literally how it’s spelled in the header, and we are not fixing it. This page is all about std::experimental::shared_ptr::operator[], and it’s here to index into an array. πŸ¦‹

✨ Synopsis ✨

element_type& operator[]( std::ptrdiff_t i ) const
noexcept;

Tagged (library fundamentals TS), bestie. This operator indexes into the array pointed to by the stored pointer. No cap.

🚨 Behavior check: the behavior is undefined if the stored pointer is null or if i is negative. Like, undefined undefined. Do not test that vibe. 😭

And if T (the template parameter of shared_ptr) is an array type U[N], then i shall be less than N, or the behavior is undefined. Periodt.

🌸 Parameters 🌸

  • i β€” the array index.

πŸŽ€ Return value πŸŽ€

A reference to the i-th element of the array, i.e., get()[i]. Slay. πŸ’–

πŸ‘‘ Remarks πŸ‘‘

Okay so here’s the chaotic little caveat: when T is not an array type, it is unspecified whether this function is declared. If the function is declared, it is unspecified what its return type is, except that the declaration (although not necessarily the definition) of the function is guaranteed to be legal. That’s the whole rule. Iykyk. 🧚

πŸ¦‹ Example πŸ¦‹

This section is incomplete Reason: no example πŸ™ˆ

πŸ”₯ See also πŸ”₯

  • get β€” returns the stored pointer (public member function).

πŸ’œ Categories πŸ’œ

  • Noindexed pages
  • Todo no example

Cute little sign-off: this is the std::experi...::operator[](3) page from the C++ Standard Libary, source/version/date http://cppreference.com / 2024.06.10. Mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from