Cleanup: Add static assert for tree-view getter template

These kind of static asserts for the base type of a template parameter
are useful, and can avoid wrong API usage.
This commit is contained in:
Julian Eisel 2021-10-27 14:55:39 +02:00
parent aae5f15238
commit 332de3a2da
1 changed files with 2 additions and 0 deletions

View File

@ -455,6 +455,8 @@ inline ItemT &TreeViewItemContainer::add_tree_item(Args &&...args)
template<class TreeViewType> TreeViewType &AbstractTreeViewItemDropController::tree_view() const
{
static_assert(std::is_base_of<AbstractTreeView, TreeViewType>::value,
"Type must derive from and implement the AbstractTreeView interface");
return static_cast<TreeViewType &>(tree_view_);
}