50 lines · cpp
1template <class T, int... Args> struct C {2 T member;3 bool argsAre_16_32() { return false; }4};5 6template <> struct C<int, 16> {7 int member;8 bool argsAre_16_32() { return false; }9};10 11template <> struct C<int, 16, 32> : C<int, 16> {12 bool argsAre_16_32() { return true; }13};14 15template <class T, typename... Args> struct D {16 T member;17 bool argsAre_Int_bool() { return false; }18};19 20template <> struct D<int, int> {21 int member;22 bool argsAre_Int_bool() { return false; }23};24 25template <> struct D<int, int, bool> : D<int, int> {26 bool argsAre_Int_bool() { return true; }27};28 29template <typename... Args> struct OnlyPack {};30template <typename T, typename... Args> struct EmptyPack {};31 32int main(int argc, char const *argv[]) {33 EmptyPack<int> emptyPack;34 OnlyPack<int, char, double, D<int, int, bool>> onlyPack;35 36 C<int, 16, 32> myC;37 C<int, 16> myLesserC;38 myC.member = 64;39 (void)C<int, 16, 32>().argsAre_16_32();40 (void)C<int, 16>().argsAre_16_32();41 (void)(myC.member != 64);42 D<int, int, bool> myD;43 D<int, int> myLesserD; // breakpoint here44 myD.member = 64;45 (void)D<int, int, bool>().argsAre_Int_bool();46 (void)D<int, int>().argsAre_Int_bool();47 48 return 0; // break here49}50