Variadic Templated Mixin Class...

I've been messing around with variadic template arguments, and I can't get a template pack to expand correctly.

error: invalid use of pack expansion expression

How would I go about to fix this?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>

template <typename ...CLASSES>
class Mixin : public CLASSES...
{
public:

    template <typename ...Args>
    Mixin(Args &&...args)
    :
    CLASSES(std::forward<Args>(args)...)...
    {}
};

class Int
{
    int n;
public:
    Int():n(0){}
    Int(int num, bool a):n(num){}
    ~Int(){}
    int get() const {return n;}
};

class Char
{
    char c;
public:
    Char():c('0'){}
    Char(char cha, bool a):c(cha){}
    ~Char(){}
    char get() const {return c;}
};

int main()
{
    Mixin<Int, Char> a(12, true, 'J', false);
    std::cout << a.Int::get() << a.Char::get() << std::endl;
    return 0;
}
bump

Works fine if I use no ctor at all, but ctor functionality is desired. I tried using initializer lists:

 
Mixin<Int, Char> a({12, true}, {'J', false});


But that doesn't work either. Anyone?
Topic archived. No new replies allowed.