// Compile with:
// clang++ -std=c++11 -stdlib=libc++ Section.cpp -o Section
#include <iostream>
using namespace std;
enum class MF : int {
ZERO = 0 ,
ONE = 1 ,
TWO = 2
} ;
// --------- Specialization -------------
template < MF mf>
class Stat{
public :
Stat( std:: string msg) {
cout << "Generic Stat construtor: " << msg << endl;
}
} ;
// --------- Template Specialization -------------
template <>
class Stat< MF:: ONE > {
public :
Stat( std:: string msg) {
cout << "Specialized Stat constructor: " << msg << endl;
}
} ;
// --------- Variadic Template -------------
template < MF mf, typename ... E >
class Var{
public :
Var( std:: string msg) {
cout << "Generic Var constructor: " << msg << endl;
}
} ;
// --------- Variadic Template Specialization -------------
template <>
class Var< MF:: TWO , MF> {
public :
Var( std:: string msg) {
cout << "Specialized Var constructor: " << msg << endl;
}
} ;
int main( ) {
cout << "I'm still trying to figure out variadic templates." << endl;
Stat< MF:: ZERO > S_MF0( "MF=0" ) ;
Stat< MF:: ONE > S_MF1( "MF=1" ) ;
Var< MF:: ZERO > MF0( "MF=0" ) ;
Var< MF:: ZERO , int > MF0_int( "MF=0,E=int" ) ;
Var< MF:: ZERO , MF> MF0_MF1( "MF=0,MF" ) ;
return 0 ;
}
Ci8vIENvbXBpbGUgd2l0aDoKLy8gIGNsYW5nKysgLXN0ZD1jKysxMSAtc3RkbGliPWxpYmMrKyBTZWN0aW9uLmNwcCAtbyBTZWN0aW9uCgojaW5jbHVkZSA8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKZW51bSBjbGFzcyBNRiA6IGludCB7CiAgICBaRVJPID0gMCwKICAgIE9ORSA9IDEsCiAgICBUV08gPSAyCn07CgovLyAtLS0tLS0tLS0gU3BlY2lhbGl6YXRpb24gLS0tLS0tLS0tLS0tLQp0ZW1wbGF0ZSA8TUYgbWY+CmNsYXNzIFN0YXR7CnB1YmxpYzoKICAgIFN0YXQoc3RkOjpzdHJpbmcgbXNnKSB7CiAgICAgICAgY291dCA8PCAiR2VuZXJpYyBTdGF0IGNv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