std::is_debugger_present(3)

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

πŸ’… NAME πŸ’…

std::is_debugger_present - std::is_debugger_present

okay bestie, welcome to std::is_debugger_present(3) from the C++ Standard Libary manual (yes, that spelling is literally in the header β€” keeping the facts exactly as they are). This page is about one function and she's lowkey iconic: she checks whether your program is running with a debugger present. 🫢

✨ Synopsis ✨

Defined in header <debugging>
bool is_debugger_present() noexcept;  (since C++26)

Attempts to determine if the program is being executed with debugger present. Like, is somebody watching? πŸ‘€

By default, the behavior of this function is completely implementation-defined. A C++ program may provide the definition of this signature to replace the behavior of this function. So the default vibe is β€œyour implementation decides”, but you can provide your own definition of this exact signature and swap the behavior out. πŸ’…

🌸 Return value 🌸

The default version returns true if, to the best of its knowledge, the program is executed under a debugger.

πŸ¦‹ Notes πŸ¦‹

The intent of this function is allowing:

  • printing out extra output to help diagnose problems
  • executing extra test code
  • displaying an extra user interface to help in debugging
  • etc.

This function standardizes many similar existing facilities:

  • under_debugger from boost.test
  • IsDebuggerPresent() from Win32 API
  • isDebuggerActive from Catch2
  • IsDebuggerPresent from Unreal Engine
  • etc.

Feature-test macro deets, and yes we're keeping every value:

  • __cpp_lib_debugging β€” 202311L β€” (C++26) β€” Debugging support library
  • __cpp_lib_debugging β€” 202403L β€” (C++26) β€” Replaceable std::is_debugger_present

πŸŽ€ Example πŸŽ€

This section is incomplete

Reason: no example

no example yet, bestie β€” the page literally says so. 😭

πŸ‘‘ See also πŸ‘‘

  • breakpoint β€” pauses the running program when called (C++26) (function)
  • breakpoint_if_debugging β€” calls std::breakpoint if std::is_debugger_present returns true (C++26) (function)

πŸ“ Category πŸ“

  • Todo no example

source/version + date sign-off: http://cppreference.com, 2024.06.10, page std::is_debugger_present(3) β€” that's the footer, and we ate. πŸ’–βœ¨

πŸ“¦ where this page comes from