Consider I inherit from a variadic template the entire arguments list. How are the arguments inherited?
// snippet
template<typename... R>
class foo
: public R... {
public:
};
// ....
using foo_inst = foo<bar_1, bar_2>;
I tried it, and it seems all R
's are inherited public (not just the first one). Is this defined behavior?
I tried it with gcc and msvc (thanks to jaggedSpire also with clang), all with same results. The compilers not even mentioned any warnings. You can see a running example here.
Yes, this is the defined behaviour. Quoting from
14.5.3[temp.variadic]\4
The relevant context from that list is:
Thus, in the parameter pack expansion
class foo : public R...
, the pattern is the base-specifierpublic R
, making the pack composed of typesT1, T2, ... , Tn
expand topublic T1, public T2, ... , public Tn
. (Ellipsis in the previous sentence are used in the mathematical sequence-specifying sense.)