boost 在它的current_function.hpp 中实现了一个宏 BOOST_CURRENT_FUNCTION ,这个宏是为了提供函数的全名,用于异常抛出、日志记录等。
有趣的是宏是在函数内部实现的。
这样做的特殊原因是什么?
....
namespace boost
{
namespace detail
{
inline void current_function_helper()
{
#if defined( BOOST_DISABLE_CURRENT_FUNCTION )
# define BOOST_CURRENT_FUNCTION "(unknown)"
#elif ...
#elif defined(__FUNCSIG__)
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
#elif ....
#else
# define BOOST_CURRENT_FUNCTION "(unknown)"
#endif
}
} // namespace detail
} // namespace boost
....
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
880 次 |
最近记录: |