c++ - 指向重载类型转换运算符的指针?

标签 c++ boost boost-phoenix

假设我有以下类(class):

class MyStringClass
{
public:
    operator const char*() const;
};

如果可能,如何创建指向此重载转换运算符的函数指针?

基本上我想使用 boost::phoenix 来调用这个运算符。我假设我需要绑定(bind)到它(因此我需要创建一个指向它的函数指针),但如果 boost::phoenix 内置了以特殊方式调用它的功能,我也对此持开放态度。

我使用的是 Visual Studio 2008,C++03。

最佳答案

const char* (MyStringClass::*ptr)() const = &MyStringClass::operator const char*;

关于c++ - 指向重载类型转换运算符的指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22465900/

相关文章:

c++ - 使用指针的二次方程问题

c++ - 在 unordered_map Boost 中插入模板值时出错

Boost Spirit 将表达式标记化为向量

struct - 升压凤凰: Binding to reference members of structures?

c++ fork()和execl()不要等待,完全分离

c++ - 具有调用者上下文的模板函数?

c++ - boost multi_index_container 更改键 -> 容器状态不正确

c++ - 用于构建 boost : "don' t know how to make <e>stage"的“阶段”参数

c++ - 使用 boost.phoenix 容器算法

c++ - 获取指向容器末尾的原始指针