deductiongu...td::weak_ptr(3)

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

🌸 NAME 🌸

okay so bestie, welcome to the deductionguidesforstd::weak_ptr page β€” it's a (3) page from the C++ Standard Libary. The NAME is literally deductionguidesforstd::weak_ptr β€” deductionguidesforstd::weak_ptr. yes, same thing twice, iconic.

✨ Synopsis ✨

it's giving header info, so here's the setup:

  • Defined in header <memory>
  • Since C++17:
template< class T >
weak_ptr( std::shared_ptr<T> ) -> weak_ptr<T>;

There's literally one deduction guide provided for std::weak_ptr, and its whole job is to account for the edge case that the implicit deduction guides missed. no cap 🫢

πŸŽ€ Example πŸŽ€

run this code, bestie:

// Run this code

#include <memory>

int main()
{
    auto p = std::make_shared<int>(42);
    std::weak_ptr w{p}; // explicit deduction guide is used in this case
}

That little comment? It's saying the explicit deduction guide is used in this case. periodt πŸ’…


mwah πŸ’‹ this page comes from http://cppreference.com, dated 2024.06.10, and it's the deductiongu...td::weak_ptr(3) page. bye bestie πŸ¦‹

πŸ“¦ where this page comes from