Compile time
// {...}
#include "gsl/gsl"
// {...}
void RunApp(gsl::not_null<App *> pApp)
{
pApp->Run();
pApp->Shutdown();
}
void DiagnoseApp(gsl::not_null<App *> pApp)
{
pApp->Diagnose();
}
int main()
{
// first case: deleting and marking as null:
{
gsl::not_null<App *> myApp = new App("Poker");
// we can delete it, but cannot assign null
delete myApp;
//myApp = nullptr;
}
// second case: breaking the contract
{
// cannot invoke such function, contract violation
//RunApp(nullptr);
}
// assigning a null on initilization
{
//gsl::not_null<App *> myApp = nullptr;
}
std::cout << "Finished...\n";
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX