为什么在函数中boost boost boost_current_function
why boost implement BOOST_CURRENT_FUNCTION in a function
boost在其current_function.hpp中实现宏boost_current_function.hpp,宏将提供功能的全名,以换取例外,记录等。
有趣的是宏是在函数内实现的。
这样做的特殊原因是什么?
....
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
....
查看完整的实现后,人们看到它使用了多个编译器特定的"函数签名"宏。这些宏当然仅在功能内有效。
测试#elif defined(__FUNCSIG__)
将在文件范围内失败。因此必须出现在功能中。在这里引入了助手为此检查提供功能范围。
MSDN上的文档证实了这一点:
- __ funcsig __ 定义为包含封闭函数的签名的字符串字面。宏仅在内部定义 功能。
相关文章:
- 如何将类成员函数与param绑定为boost::function的右值
- 自 1.55 以来,boost::bind / boost::function 中的奇怪行为变化
- 将 boost::function 与指向派生类的共享指针的参数一起使用
- 将 boost::function 和 boost::bind 替换为模板
- 如何从“boost::function”中获取 C 指针(如 'var (*)(vo
- 如何使用 boost::bind 将静态成员函数绑定到 boost::function
- 以 C++11 方式重写 boost 风味代码(Boost.Bind、Boost.Function)
- Boost:bind and Boost::function
- 将模板函数分配给 boost::function
- boost::function 和 std::tr1::function 之间是否有重要的区别需要了解
- 将 boost::function 与实例方法一起使用
- 将 Python 函数作为 Boost.Function 参数发送
- 将 C++11 std::function 传递给采用 boost::function 的遗留函数是否安全?
- 将 boost::function 转换为 std::function
- 使用 boost::bind 和 boost::function 将成员函数分配给回调
- 将赋值运算符绑定到 boost::function 对象
- 如何在"boost::function"中访问类实例(对象)指针?
- llvm g++ and boost function
- Using boost::function and boost::bind
- 为什么使用boost::function调用函数对象时不需要类实例