Compile-time constant id

前端 未结 16 2145
不知归路
不知归路 2020-12-02 20:06

Given the following:

template
class A
{
public:
    static const unsigned int ID = ?;
};

I want ID to generate a unique c

16条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 20:21

    Use the memory address of a static function.

    template
    class A  {
    public:
        static void ID() {}
    }; 
    

    (&(A::ID)) will be different from (&(A::ID)) and so on.

提交回复
热议问题