Tech Off Post

Single Post Permalink

View Thread: template countof confusion-question
  • User profile image
    Mr Crash

    Mr Crash said:

    Here's another one i found a few days ago,while searching for an answer:

     

    From: http://blogs.msdn.com/b/the1/archive/2004/05/07/128242.aspx

    I modified it to work in vs2010, i think i'm using decltype correctly here but i'm not sure ( decltype == typeof ? ) 

     

    template <class T> class ArraySize { }; template <class T, size_t N> class ArraySize<T[N]> { public: static const size_t value = N; }; //#define countofTEST(x) (ArraySize<typeof(x)>::value) // for GCC compiler #define countofTEST(x)
     (ArraySize<decltype(x)>::value) // works in vs2010 

     

     

    No one capable of answering these questions ?  Sad
    No c++/compiler experts around ? <shocked>