mesos/3rdparty/stout/include/stout/err.hpp
=======================================================
struct Exit2
{
Exit2(int _status) : status(_status) {}
NORETURN ~Exit2()
{
std::cerr << out.str() << std::endl;
exit(status);
}
std::ostream& stream()
{
return out;
}
std::ostringstream out;
const int status;
};
int main() {
Exit2(EXIT_FAILURE).stream() << "qwerer";
return 0;
}
======================================================
#define NORETURN __attribute__((noreturn)) 只有析构函数可以用,前边加波浪线的
=========================================================
#define MyExit(status) Exit2(status).stream()
int main() {
MyExit(EXIT_FAILURE) << "error---------";
return 0;
}
========================================================