std :: destroy对基本类型是否无效?

I often write something like this to prevent std::destroy from looping through arrays of elements that do not need to be destroyed but I have no idea if it is actually useful in any way.

if constexpr (!std::is_fundamental_v<element_type>) {

    std::destroy(container_begin(), container_end());

}

Will dropping if constexpr statement change anything in the behavior of this code?

评论