![](/img/trans.png)
[英]How to check if a class has specific function to avoid compile time issues?
[英]How to check, if the class is abstract, at compile time?
通過抽象類我的意思是具有至少一個純虛方法的類。 如果檢查顯示該類不是抽象的,我希望編譯失敗。
它甚至可能嗎?
使用std::is_abstract
。
#include <type_traits>
static_assert(std::is_abstract<T>(), "T ought to be abstract.");
看到它在行動 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.