当std :: is_array应该返回false时返回true?

时间:2018-02-28 16:53:43

标签: c++ std

我已经创建了一个静态断言,以确保我不会调用我的辅助函数来创建一个唯一的指针(它是我的内存调试代码的一部分)。

我面临的问题是,当T不是数组时,断言似乎就会消失。

功能:

template<class T> n::c_uptr<T> mem::make_unique() {
    static_assert(std::is_array_v<T>, "T must not be an array.");

    return n::c_uptr<T>(nullptr, [](T * pv_object) { });
}

函数调用:

private: a_row_uptr iv_row = n::mem::make_unique<a_row>();

a_row是一个抽象类,我也尝试使用!std::is_abstract_v<T> && std::is_array_v<T>

3>class_method_definitions\mem.h(122): error C2338: T must not be an array.
3>class_definitions\db\a_result.h(6): note: see reference to function template instantiation 'std::unique_ptr<n::db::a_row,std::function<void (_Ty *)>> n::mem::make_unique<n::db::a_row>(void)' being compiled
3>        with
3>        [
3>            _Ty=n::db::a_row
3>        ]

1 个答案:

答案 0 :(得分:1)

显然我需要反转条件语句,因为它会在评估为假时触发错误,而不是真实。

相关问题