I think my problem is best explained with how I want the code to look. Only problem is it doesn't work (Line 11). I have some experience with templates but I'm not a pro.
Basically I want the "Channels<3>" to be a type that I can use to specify a Cable with similar to vector<float/int> it would be Cable<Channels<2 or 3>>.
I don't really like the 2nd and 3rd because they don't have the syntax I would like. I really want the syntax " Cable<Static_Property<value>> " for some really nice flexibility when things get more complicated.
With the first solution, it breaks with any type that has a "channels" property...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
template<int channel_count>
struct Channels {
staticconstint channels = channel_count;
};
//adding this...
template<int channel_count>
struct Tricked {
staticconstexprint channels = channel_count;
};
int main() {
// compiles...
// but that makes no sense
Cable< Tricked<3> > c;
return 0;
}
I want to add specialization later on based on Cable<Channels<2>>, Cable<Channels<3>>, etc that do specific mixing, or connections/io and at a minimum the number of channels have to match. It would be nice to catch that at compile time.
So something like this would work...
1 2 3 4 5 6 7
Mixer< Slots<20>, Cable<Channels<3>> > m;
Cable<Channels<2>> c2;
Cable<Channels<3>> c3;
m.add_to_mix(c3); // ok
m.add_to_mix(c2); // should fail
> I really want the syntax " Cable<Static_Property<value>> "
> it breaks with any type that has a "channels" property...
> It would be nice to catch that at compile time.