|
Boost Users : |
From: Jack Nguyen (bluekite2000_at_[hidden])
Date: 2005-07-22 12:48:47
Here is the compilable code:
#include <boost/shared_array.hpp>
#include <iostream>
template <typename T> class VectorView;
template <typename T>
inline std::ostream& operator << (std::ostream& os, const VectorView<T>& VOut)
{
os<<VOut.size()<<std::endl;
for (int i=0; i<VOut.size() && os.good(); ++i){
os<<VOut(i)<<"";
os<<std::endl;
}
return os;
}
template<typename T>
class VectorView
{
private:
int _size;
boost::shared_array<T> _vp;
public:
VectorView(T* ptr, int size)
{
_size=size;
_vp=boost::shared_array<T>(ptr);
}
T operator () (int pos) const
{
return _vp[pos];
}
int size() const
{
return _size;
}
~VectorView()
{
}
};
int main (void)
{
double a[]={1,2,3,4,5,6,7};
VectorView<double>V(a,4);
std::cout<<V;
return 0;
}
Any workaround?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net