Stroika Library
3.0d18
Help-Home
Loading...
Searching...
No Matches
Foundation/Debug/Main.h
1
/*
2
* Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3
*/
4
#ifndef _Stroika_Foundation_Debug_Main_h_
5
#define _Stroika_Foundation_Debug_Main_h_ 1
6
7
#include "Stroika/Foundation/StroikaPreComp.h"
8
9
#include <optional>
10
11
#include "Stroika/Foundation/Common/Common.h"
12
13
namespace
Stroika::Foundation::Debug {
14
15
/**
16
* This returns true iff it is highly likely that we are executing after the start of main (in the main thread)
17
* and before the end of main.
18
*
19
* This is IMPORTANT, because certain things are required/allowed by C++ only after the start and before the end of main.
20
* But alas, C++ provides no reliable way to test this.
21
*
22
* This function - since unreliable - is only to be used for generating assertions.
23
*
24
* \note - this function may false POSITIVE, but will never false NEGATIVE.
25
*
26
* That is to say - it's perfectly safe to say
27
* Assert (Debug::AppearsDuringMainLifetime ()); // in threaded code
28
*
29
* The assertion may sometimes fail to trigger when you would want it to, but it will never trigger falsely.
30
*
31
* \todo FIND CLEAR DOCS on WHY this is hard, and clear docs on WHY this is useful (threads). I found neither on
32
* a quick search of the C++ specification.
33
*
34
* \note Stroika's AllThreadsDeadDetector_ will attempt to detect/assert if any threads left running after main.
35
*/
36
bool
AppearsDuringMainLifetime ();
37
38
}
39
40
#endif
/*_Stroika_Foundation_Debug_Main_h_*/
Library
Sources
Stroika
Foundation
Debug
Main.h
Generated by
1.9.8