lundi 9 mars 2020

Forwarding variadic arguments in std::enable_if via other function

Following issue:

    template <typename... Args>
    inline constexpr size_t variadicElementCounter(Args... args)
    {
        return sizeof...(args); // get num of arguments in the parameter pack
    }

    class Sth
    {
     Sth()=default;
     ~Sth()=default;

     template<typename ... VariadicValues, enable_type_if_t<(variadicElementCounter(VariadicValues...)) == SizeValue> * = nullptr>
        Sth(VariadicValues && ... f_values) noexcept : m_arr{ std::move(f_values) ...}
        {

        }
     }

Trying to compile this class, the VariadicValues... (probably) breaks the compilation What am I doing wrong (because I want to avoid calling return...(VariadicValues) in the enable_if expression

Aucun commentaire:

Enregistrer un commentaire