开发者

C++ template determine function return type

How can I go about determining return type of a member generic function?

    template<class E>
    struct result<E> {
        // E has member function data(), I need to know its retu开发者_如何学Crn type
        typedef typename &E::data type;
    };

is it possible to do it in generic way? I know there is boost:: result_of but for my purposes it lacks specializations (if I understood correctly, return type must be specialized). boost implementation would be great.


GCC's nonstandard typeof operator can do this, as can Boost.TypeOf.


If you're using VS2010 or GCC 4.3 at least you can use C++0x new keyword decltype .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜