std::type_index::name(3)

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

πŸ¦‹ std::type_index::name(3) Β· C++ Standard Libary πŸ¦‹

okay bestie, welcome to the std::type_index::name(3) page from the C++ Standard Libary manual β€” yes, that’s the manual name, spelling and all, and she’s iconic. πŸ’…


✨ NAME ✨

std::type_index::name β€” std::type_index::name. That’s it, that’s the name, no cap. It’s giving β€œsame thing on both sides” but make it make sense: this is the page for the name() part of std::type_index. 🫢


πŸŽ€ Synopsis πŸŽ€

const char* name() const noexcept;  (since C++11)

Returns the name of the associated std::type_info object. Equivalent to calling std::type_info::name() directly β€” same energy, no extra steps. ✨


🫢 Parameters 🫢

  • (none) β€” literally no parameters, bestie. Not a single one. πŸ’…

⭐ Return value ⭐

The name of the associated std::type_info object. That’s the whole return value. Slay. 🌸


πŸ“ Example πŸ“

// Run this code

#include <iostream>
#include <typeindex>
int main() {
    std::cout << std::type_index(typeid(std::cout)).name();
}

🌈 Possible output: 🌈

NSt3__113basic_ostreamIcNS_11char_traitsIcEEEE

πŸ’€ Defect reports πŸ’€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards β€” here’s the tea: 🍡

  • DR: LWG 2144 β€” Applied to: C++11. Behavior as published: type_index::name was not required to be noexcept. Correct behavior: required noexcept.

source/version: http://cppreference.com Β· date: 2024.06.10 β€” signing off with the cutest little manual-page footer energy, bestie. Go call .name() and slay. πŸ’–πŸ‘‘

πŸ“¦ where this page comes from