Absence of typeof operator in C++03?

后端 未结 5 1138
半阙折子戏
半阙折子戏 2020-12-05 21:44

I\'m just wondering how boost have implemented BOOST_TYPEOF (in C++03) which seems to be a very useful tool. Anyone has any idea?

Also, I\'m thinking C++03 itself co

5条回答
  •  爱一瞬间的悲伤
    2020-12-05 22:05

    It's defined as:

    #define BOOST_TYPEOF(Expr) \
    boost::type_of::decode_begin::type
    

    I don't know the details, but it seems to look up the type in some sort of table, and expands to (the table entry)::type

    No, it's not possible to know the size without knowing the type. It's just that nobody thought to add typeof to C++03.

提交回复
热议问题