Sep 19, 2017 at 6:41am UTC
I am trying to code OpenCin function that will open cin ili cwin in the function whether we deal with chars or w_chars.
template <class T>
basic_istream<T, char_traits<T> > *is;
template <class T>
inline std::basic_istream<char,char_traits<char> > * cin_assign(char dummy){
return &cin;
}
template<class T>
inline std::basic_istream<wchar_t,char_traits<wchar_t> > * cin_assign(wchar_t dummy) {
return &wcin;
}
template<class T>
void OpenCin(T dummy) {
is = cin_assign(T dummy);
}
int man ()
{
char cTest = 'a';
OpenCin(cTest);
return 0;
}
The error on Linux (with c11) is:
testcin.cpp:15:5: error: missing template arguments before ‘=’ token
is = cin_assign(T dummy);
^
testcin.cpp:15:20: error: expected primary-expression before ‘dummy’
is = cin_assign(T dummy);
^~~~~
What I have done wrong?
Last edited on Sep 19, 2017 at 6:45am UTC
Sep 24, 2017 at 2:06pm UTC
May I ask what is the meaning CHAR_TYPE{} ? I mean {}....