forked from Alepha/Alepha
Add some compile time checking for abuse of error
.
This commit is contained in:
7
error.h
7
error.h
@ -41,7 +41,8 @@ namespace Alepha::Hydrogen ::detail:: error_m
|
||||
* local named variable is going to cause the lock to be released. While this is not
|
||||
* a fatal problem, it can result in torn error lines, once again.
|
||||
*/
|
||||
std::ostream &error( const std::lock_guard< SecretMutex > & );
|
||||
template< typename ... Args >
|
||||
std::ostream &error( Args..., const std::lock_guard< SecretMutex > & );
|
||||
|
||||
// Not threadsafe. Set in or before main, before starting any threads.
|
||||
void setErrorStream( std::ostream &os );
|
||||
@ -52,8 +53,10 @@ namespace Alepha::Hydrogen ::detail:: error_m
|
||||
// The default is `std::cerr`, but any `std::ostream` will do.
|
||||
inline std::ostream *errorStream= &std::cerr;
|
||||
|
||||
template< typename ... Args >
|
||||
requires( sizeof...( Args ) == 0 )
|
||||
inline std::ostream &
|
||||
exports::error( const std::lock_guard< SecretMutex > & = std::lock_guard{ access } )
|
||||
exports::error( Args..., const std::lock_guard< SecretMutex > & = std::lock_guard{ access } )
|
||||
{
|
||||
return *errorStream;
|
||||
}
|
||||
|
Reference in New Issue
Block a user