R
red floyd
I'm playing with template template parameters. I'm not
sure what I'm doing wrong here. Could someone with better
template template experience give me a hand?
Code and Comeau online error below.
#include <vector>
template<template<typename> class C, typename T>
T* iterator_cast(typename C<T>::iterator it)
{
return &*it;
}
int* cast_tester(std::vector<int>& c)
{
return iterator_cast(c.begin()); // line 12
}
Comeau online gives me the following error (G++ 3.4.4 gives a similar errr):
"ComeauTest.c", line 12: error: no instance of function template
"iterator_cast"
matches the argument list
The argument types that you used are: (std::vector<int,
std::allocator<int>>::iterator)
return iterator_cast(c.begin());
sure what I'm doing wrong here. Could someone with better
template template experience give me a hand?
Code and Comeau online error below.
#include <vector>
template<template<typename> class C, typename T>
T* iterator_cast(typename C<T>::iterator it)
{
return &*it;
}
int* cast_tester(std::vector<int>& c)
{
return iterator_cast(c.begin()); // line 12
}
Comeau online gives me the following error (G++ 3.4.4 gives a similar errr):
"ComeauTest.c", line 12: error: no instance of function template
"iterator_cast"
matches the argument list
The argument types that you used are: (std::vector<int,
std::allocator<int>>::iterator)
return iterator_cast(c.begin());