std::stackt...source_line(3)

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

πŸ’– NAME πŸ’–

Okay bestie, welcome to the std::stackt...source_line(3) page from the C++ Standard Libary manual β€” yes, that manual name is exactly how it appears, no cap. The function is std::stacktrace_entry::source_line, and it's here to hand you a line number: 1-based, lexically related to the evaluation that *this represents. If it can't do that, it gives you 0 on failure other than allocation failure, e.g. when *this is empty. ✨

✨ Synopsis ✨

std::uint_least32_t source_line() const;  (since C++23)

Returns a 1-based line number that lexically relates to the evaluation represented by *this, or 0 on failure other than allocation failure, e.g. when *this is empty.

Either source_file returns the presumed source file name and source_line returns the presumed line number, or source_file returns the actual source file name and source_line returns the actual line number. That's the whole either/or vibe, periodt. πŸ‘‘

🌸 Parameters 🌸

(none) β€” literally nothing to pass in. πŸŽ€

πŸ¦‹ Return value πŸ¦‹

The line number specified above on success, 0 on failure other than allocation failure. No cap. ✨

πŸ”₯ Exceptions πŸ”₯

Throws std::bad_alloc if memory for the internal data structures cannot be allocated. That's the only exception tea here. πŸ’€

πŸ’… Notes πŸ’…

The presumed line number is what the predefined macro __LINE__ expands to, and can be changed by the #line directive. Big preprocessor energy, iykyk.

This section is incomplete Reason: definition of "actual line number" is missing (LWG issue 3507)

This function is not required to be noexcept because getting source line requires allocation on some platforms. So yeah, allocation can be part of the plot. 😭

🧚 Example 🧚

This section is incomplete Reason: no example

No example, bestie β€” the example section is literally off getting boba. πŸ“

🌈 See also 🌈

  • line β€” return the line number represented by this object (public member function of std::source_location)

πŸ‘‘ Categories πŸ‘‘

  • Todo with reason
  • Todo no example

Bye bestie 🫢 β€” this cutie's source/version/date sign-off is http://cppreference.com, 2024.06.10, with the footer title std::stackt...source_line(3). πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from