C++ -- typedef "inside" template arguments?
- by redmoskito
Imagine I have a template function like this:
template<Iterator>
void myfunc(Iterator a, Iterator::value_type b)
{ ... }
Is there a way to declare a typedef for Iterator::valuetype that I can use in the function signature? For example:
template<
typename Iterator,
typedef Iterator::value_type type>
void myfunc(Iterator a, type b)
{ ... }
Thus far, I've resorted to using default template arguments and Boost concept checking to ensure the default is always used:
template<
typename Iterator,
typename type = Iterator::value_type >
void myfunc(Iterator a, type b)
{
BOOST_STATIC_ASSERT((
boost::type_traits::is_same<
typename Iterator::value_type,
type
>::value
));
...
}
...but it would be nice if there was support in the language for this type of thing.