- Document number:
ISO/IEC JTC1/SC22/WG21 14882: Programming Language — C++
René Ferdinand Rivera Morell - grafikrobot at gmail dot com
Ben Craig - ben dot craig at gmail dot com
This proposes to add
std::is_debugger_present, proposed in P2546
to the set of replacement functions to allow users the flexibility to control
the result of the function when otherwise it would not be possible to determine
the platform specific result.
The debugging support proposed in P2546
 defines its functions as available in
both hosted and freestanding realms. In it the
function poses some challenges for embedded platforms where determining the
circumstances of debuggers in a freestanding environment is most times
impossible. Hence it is reasonable to allow the user to control what the
function returns by some means. While some options are possible, like
environment variables, platform configuration files, alternate runtime
implementations, they are not ideal. As even those options may not be
implementable for the platform. It is also ideal to not remove the function
from freestanding as that will complicate the use of the functions with macro
checks and alternative implementations. Placing the C++ ecosystem in yet more
reliance on the preprocessor.
The option we propose is to allow users to replace the function in their programs, i.e. a replaceable function. This has the benefits of giving users the ability to overcome any deficiencies in the default platform implementation and to have fine control over the result even on hosted platforms. Possible user implementations could:
Wire it to return
truein special verifying builds of their application.
Wire it to return
truefrom external input like: a key press or other external mechanical signal, a software signal as might be caught by a process signal handler, and so on.
Wording is relative to P2546R3. 
Insert the following paragraph between [replacement.functions] par. 2 and par. 3.
A C++ program may provide the definition of the following function signature
declared in header
bool std::is_debugger_present() noexcept
Add the following clause after the "Returns" clause of
Replaceable: A C++ program may define a function with the function signature, and thereby displace the default version defined by the C++ standard library.