Created
June 25, 2012 07:13
-
-
Save thefloweringash/2987134 to your computer and use it in GitHub Desktop.
C++11 Variadic Template Pattern Matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <typename... T> | |
struct pp {}; | |
template <typename T, typename TI, | |
typename U, typename UI> | |
struct matcher; | |
template <typename T, typename... TI, | |
typename U, typename... UI> | |
struct matcher<T, pp<TI...>, | |
U, pp<UI...>> { | |
matcher(TI... ti, UI... ui) { | |
cout << "TI size = " << sizeof...(ti) << endl | |
<< "UI size = " << sizeof...(ui) << endl; | |
} | |
}; | |
using matcher_test = matcher<int, pp<int>, | |
int, pp<int>>; | |
int main() { | |
matcher_test(0, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment