Why does c++ require a template argument when both out
member functions (from the template and from the specialization) need a template, because I'm not getting it and google is not helping. Must be c++11 but have the same error with c++1z.
I'm using g++ 7.3.0
getting this error message:
error: missing template arguments before ‘>’ token
Tail::out<P>(o);//<--?!?!?!
#include <iostream>
using namespace std;
using Out=ostream;
struct O {};
template<typename O=O>
struct Static:public O {
template<const char** text>
struct Text {
static inline void print(Out& o) {o<<text[0];}
};
};
template<typename O>
struct Endl {
static inline void print(Out& o) {O::print(o);o<<endl;}
};
template<typename O,typename... OO>
struct MenuData {
using Head=O;
using Tail=MenuData<OO...>;
template<template<typename> class P>
static inline void out(Out& o) {
P<O>::print(o);
Tail::out<P>(o);//<--?!?!?!
}
};
template<typename O,typename OO>
struct MenuData<O,OO> {
using Head=O;
using Last=OO;
template<template<typename> class P>
static inline void out(Out& o) {P<O>::print(o);P<Last>::print(o);}
};
/////////////////////////////////////////////////////////
const char* op1Text="Op1";
using op1=Static<>::Text<&op1Text>;
const char* op2Text="Op2";
using op2=Static<>::Text<&op2Text>;
const char* op3Text="Op3";
using op3=Static<>::Text<&op3Text>;
using MainMenu=MenuData<op1,op2,op3,op1>;
int main(int argc,char** argv) {
MainMenu::out<Endl>(cout);
cout<<endl;
}