J
Joseph Turian
Examples is a vector of some EXAMPLE type (templated).
ExamplePtrs is a vector of some EXAMPLE* type.
They both contain the same methods, except the latter is dereferencing
pointers whereas the former is just working with EXAMPLE objects
directly.
(I'm sure there's a smarter way to do this with template without
defining two classes, but whatever. It works for me now, and my
question is about something else.)
I want to write a method Examples:trs() to return a boost::shared_ptr
to an ExamplePtrs type:
===
template<typename EXAMPLE> class ExamplePtrs;
template <typename EXAMPLE>
class Examples : public vector<EXAMPLE> {
public:
...
template <typename EXAMPLE>
class ExamplePtrs : public vector<EXAMPLE*> {
public:
....
}
===
Notice that Examples:trs() is templated, because I would like---for
example---to take a Examples<E> and call ptrs() and have it return a
boost::shared_ptr<ExamplePtrs<const E> > (const'ing the ptrs). So far,
the above syntax seems okay. But the question is, how do I call
function ptrs()?
Here's what I'm trying to do, except it doesn't compile:
Examples<E> exmpls;
boost::shared_ptr<ExamplePtrs<const E> > eptrs = exmpls.ptrs<const
E>();
How can I specify the specific type instantiation needed?
Thanks,
Joseph
ExamplePtrs is a vector of some EXAMPLE* type.
They both contain the same methods, except the latter is dereferencing
pointers whereas the former is just working with EXAMPLE objects
directly.
(I'm sure there's a smarter way to do this with template without
defining two classes, but whatever. It works for me now, and my
question is about something else.)
I want to write a method Examples:trs() to return a boost::shared_ptr
to an ExamplePtrs type:
===
template<typename EXAMPLE> class ExamplePtrs;
template <typename EXAMPLE>
class Examples : public vector<EXAMPLE> {
public:
...
};template said:ptrs() const;
template <typename EXAMPLE>
class ExamplePtrs : public vector<EXAMPLE*> {
public:
....
}
===
Notice that Examples:trs() is templated, because I would like---for
example---to take a Examples<E> and call ptrs() and have it return a
boost::shared_ptr<ExamplePtrs<const E> > (const'ing the ptrs). So far,
the above syntax seems okay. But the question is, how do I call
function ptrs()?
Here's what I'm trying to do, except it doesn't compile:
Examples<E> exmpls;
boost::shared_ptr<ExamplePtrs<const E> > eptrs = exmpls.ptrs<const
E>();
How can I specify the specific type instantiation needed?
Thanks,
Joseph