From 4addf2a48646f5b0faa5f42b35a5735d40d8b4f0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 10 Feb 2011 16:16:40 -0800 Subject: uhd: reference vector fix revealed when building w/ debug --- host/include/uhd/types/ref_vector.hpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/host/include/uhd/types/ref_vector.hpp b/host/include/uhd/types/ref_vector.hpp index ef970802f..efd4b8f89 100644 --- a/host/include/uhd/types/ref_vector.hpp +++ b/host/include/uhd/types/ref_vector.hpp @@ -29,29 +29,22 @@ namespace uhd{ */ template class ref_vector{ public: - //! Create a reference vector of length one from a pointer - template ref_vector(Ptr *ptr): - _mem(memp_t(&ptr)), _size(1) + //! Create a reference vector from a pointer and size + template ref_vector(Ptr *ptr, size_t size = 1): + _mem(T(ptr)), _size(size) { /* NOP */ } //! Create a reference vector from a std::vector container template ref_vector(const Range &range): - _mem(memp_t(&range[0])), _size(range.size()) + _mem(T(range.front())), _size(range.size()) { /* NOP */ } - //! Create a reference vector from a memory pointer and size - ref_vector(T *mem, size_t size): - _mem(mem), _size(size) - { - /* NOP */ - } - - T &operator[](size_t index) const{ - return _mem[index]; + const T &operator[](size_t index) const{ + return (&_mem)[index]; } size_t size(void) const{ @@ -59,8 +52,7 @@ public: } private: - typedef T* memp_t; - const memp_t _mem; + const T _mem; const size_t _size; }; -- cgit v1.2.3