Imagine I have a template function like this:
template<typename Iterator>
void myfunc(Iterator a, typename Iterator::value_type b)
{ ... }
Is there a way to implement the same thing by declare a typedef for Iterator::valuetype that I can use in the function signature? For example, I'd prefer to be able to do something like this:
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 = typename Iterator::value_type >
void myfunc(Iterator a, type b)
{
BOOST_STATIC_ASSERT((
boost::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.
Edit
I probably should have used a class instead of a function, since default arguments aren't standard for functions.
template<
typename T,
typename V = typename T::value_type>
class A : public B<T, V>
{
BOOST_STATIC_ASSERT((boost::is_same<typename T::value_Type, V>::type));
};