#ifndef ZFP_REFERENCE4_HPP #define ZFP_REFERENCE4_HPP namespace zfp { namespace internal { namespace dim4 { // const reference to a 4D array or view element template class const_reference : const_handle { public: typedef Container container_type; typedef typename container_type::value_type value_type; // constructor explicit const_reference(const container_type* container, size_t x, size_t y, size_t z, size_t w) : const_handle(container, x, y, z, w) {} // inspector operator value_type() const { return get(); } // pointer to referenced element const_pointer operator&() const { return const_pointer(container, x, y, z, w); } protected: using const_handle::get; using const_handle::container; using const_handle::x; using const_handle::y; using const_handle::z; using const_handle::w; }; // reference to a 4D array or view element template class reference : public const_reference { public: typedef Container container_type; typedef typename container_type::value_type value_type; // constructor explicit reference(container_type* container, size_t x, size_t y, size_t z, size_t w) : const_reference(container, x, y, z, w) {} // copy constructor (to satisfy rule of three) reference(const reference& r) : const_reference(r.container, r.x, r.y, r.z, r.w) {} // assignment reference operator=(const reference& r) { set(r.get()); return *this; } reference operator=(value_type val) { set(val); return *this; } // compound assignment reference operator+=(value_type val) { container->add(x, y, z, w, val); return *this; } reference operator-=(value_type val) { container->sub(x, y, z, w, val); return *this; } reference operator*=(value_type val) { container->mul(x, y, z, w, val); return *this; } reference operator/=(value_type val) { container->div(x, y, z, w, val); return *this; } // pointer to referenced element pointer operator&() const { return pointer(container, x, y, z, w); } // swap two array elements via proxy references friend void swap(reference a, reference b) { value_type x = a.get(); value_type y = b.get(); b.set(x); a.set(y); } protected: // assign value through reference void set(value_type val) { container->set(x, y, z, w, val); } using const_reference::get; using const_reference::container; using const_reference::x; using const_reference::y; using const_reference::z; using const_reference::w; }; } // dim4 } // internal } // zfp #endif