aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-10 16:16:40 -0800
committerJosh Blum <josh@joshknows.com>2011-02-10 16:16:40 -0800
commit4addf2a48646f5b0faa5f42b35a5735d40d8b4f0 (patch)
tree475d735bede768e45f89872c0b71f25c2d98a940 /host/include
parent5845c437dddb1e6d661054a4388c9db6f6f06e73 (diff)
downloaduhd-4addf2a48646f5b0faa5f42b35a5735d40d8b4f0.tar.gz
uhd-4addf2a48646f5b0faa5f42b35a5735d40d8b4f0.tar.bz2
uhd-4addf2a48646f5b0faa5f42b35a5735d40d8b4f0.zip
uhd: reference vector fix revealed when building w/ debug
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/types/ref_vector.hpp22
1 files 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 <typename T> class ref_vector{
public:
- //! Create a reference vector of length one from a pointer
- template <typename Ptr> ref_vector(Ptr *ptr):
- _mem(memp_t(&ptr)), _size(1)
+ //! Create a reference vector from a pointer and size
+ template <typename Ptr> ref_vector(Ptr *ptr, size_t size = 1):
+ _mem(T(ptr)), _size(size)
{
/* NOP */
}
//! Create a reference vector from a std::vector container
template <typename Range> 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;
};