mercredi 21 mars 2018

Why is it an error to const-qualify a parameter pack of pointers?

When implementing a function which accepts a parameter pack of pointers to Ts..., why can't I const-qualify the pointers, as is possible with regular parameters?

I get a mismatching signature error on all latest compilers, and I don't see why, since the pointers being const is just an implementation detail (hence it being legal for regular parameters).

template<typename... Ts>
class C
{
    void f(int*);
    void g(Ts*...);
};

template<typename... Ts>
void f(int* const) {} // Legal

template<typename... Ts>
void C<Ts...>::g(Ts* const...) {} // Compiler error

https://wandbox.org/permlink/VmCbbm0zlszBITGJ

Aucun commentaire:

Enregistrer un commentaire