singleton: add "maybe" pointer accessor
This commit is contained in:
parent
ca192ef4d8
commit
9153155076
@ -71,15 +71,25 @@ namespace cruft {
|
||||
}
|
||||
|
||||
|
||||
/// returns a reference to sole instantiated value
|
||||
/// Returns a reference to the instantiated value.
|
||||
///
|
||||
/// `instantiate` must have already been called before `get` is called.
|
||||
/// `instantiate` must have already been called before `get` is called
|
||||
/// otherwise the results are undefined.
|
||||
static SelfT&
|
||||
get (void)
|
||||
{
|
||||
CHECK (instance);
|
||||
return *instance;
|
||||
}
|
||||
|
||||
|
||||
/// returns a pointer to the instantiated value if it exists, else we
|
||||
/// return nullptr.
|
||||
static SelfT*
|
||||
maybe (void)
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user