Reputation: 720
I have inherited some code and am stuck on what I thought should be a simple update.
I have the following function
template<typename T>
class ArrayRef {
public:
typedef const T *iterator;
typedef const T *const_iterator;
private:
/// The start of the array, in an external buffer.
const T *Data;
public:
/// Construct an ArrayRef from a std::vector.
template<typename A>
ArrayRef(const std::vector<T, A> &Vec)
: Data(Vec.empty() ? (T*)0 : &Vec[0]), Length(Vec.size()) {}
};
And I need to pass a vector, defined with following, to that function.
std::vector<const myType*> myVector(4);
What is the simplest way to do this?
Upvotes: 0
Views: 451
Reputation: 8036
Just pass your vector:
ArrayRef<const myType*> myArrayRef(myVector);
Is there some reason this doesn't work for you?
Upvotes: 1