草庐IT

IsDestructorPrivate

全部标签

c++ - 确定 C++ 类是否具有私有(private)析构函数

假设我有以下代码:classExample{#ifndefPRIVATE_DESTRUCTORpublic:#endif~Example(){}public:friendclassFriend;};classFriend{public:voidMember();};voidFriend::Member(){std::printf("Example'sdestructoris%s.\n",IsDestructorPrivate::value?"private":"public");}是否可以实现上面的IsDestructorPrivate模板来确定类的析构函数是private还是prot