variable-templates

    8熱度

    2回答

    隨着可變模板C++ 14來(和鏘已經支持他們)和標準is_same_v的建議,同樣類型的特質,我想能夠做出新的類型特點如下是整齊: template<typename T> constexpr bool is_const_and_volatile{std::is_const_v<T> && std::is_volatile_v<T>}; 唉,這導致等同於以下SSCCE錯誤(this one包

    4熱度

    1回答

    我去看看你是否可以在變量模板聲明中使用auto。 template <typename T> auto F = T{}; 好,但只要你嘗試使用它,鏗鏘喳喳。 int f = F<int>; // error: cannot initialize a variable of type 'int' with an lvalue of type 'auto' auto f = F<int>; /