M
Marcin Kalicinski
Hi,
How to convert a type inside a template from pointer to type to type itself?
struct S { };
template<class It> void f(It begin, It end)
{
// When called from g(), It::value_type is a pointer to S, but
// I want to get S itself, for example to use it in an auto_ptr:
auto_ptr<It::*value_type> ap = **begin; // this will not work
}
void g()
{
std::vector<S *> v;
f(v.begin(), v.end());
}
There's a way to make pointer type from regular type (just by adding *), but
is there a way to do the reverse?
Best regards,
Marcin
How to convert a type inside a template from pointer to type to type itself?
struct S { };
template<class It> void f(It begin, It end)
{
// When called from g(), It::value_type is a pointer to S, but
// I want to get S itself, for example to use it in an auto_ptr:
auto_ptr<It::*value_type> ap = **begin; // this will not work
}
void g()
{
std::vector<S *> v;
f(v.begin(), v.end());
}
There's a way to make pointer type from regular type (just by adding *), but
is there a way to do the reverse?
Best regards,
Marcin