怎样让C++函数重载时连返回值类型也加入重载决议?
摘要:
众所周知,C++函数重载时返回值是不参与重载决议的, 也就是说:int lex_cast(const char*);double lex_cast(const char*);这样两个函数在同一个编译单元同一个 namespace 中时, 会编译报错.怎么办呢?一个小技巧:#include #include #include class my_cast { const char* s;public: template operator Target() const { return boost::lexical_cast(s); } my_cast(c... 阅读全文
posted @ 2011-09-07 11:35 能发波 阅读(198) 评论(0) 推荐(0)