template<>?
От: mic_o_stas NA
Дата: 23.12.01 14:26
Оценка:
Два вопросика по темплэйтам :
1. Как ( если это вообще возможно ) задать частичную специализацию?
Например:
template< class Arg, class Result >
class os_pointer_to_unary_function
{
...
Result operator( const Arg& a){ return prt(a);}
protected:
Result ( *ptr )( Arg );
};

В случае Arg или Result является void всё это не очень компилируется. Нельзя ли как-то написать специализации для
подобного вырождения, что то типа

template< void, class Result >
class os_pointer_to_unary_function
{
...
Result operator){ prt(a);}
protected:
Result ( *ptr )( );
};

2. Почему VC6 компилятор так считает
'identifier' : template parameter can never be initialized

There was an attempt to declare a structure or union argument to a template. The structure or union cannot be initialized. Use pointers to pass structures and unions as template parameters. The following code generates this error:

struct MyStruct {
int a;char b;
};
template <class T, struct MyStruct S> {}; // error
Stas
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.