AMDG jesseperla wrote:
A followup if anyone else is using this code:
Steven: Your code worked beautifully, but it turned out that I also needed an assignment operator (which fails due to the const on the ref). For now, I did the following: typedef boost::add_reference<boost::add_const<boost::mpl::_1> > > const_reference_policy; typedef boost::add_reference<<boost::mpl::_1 > > reference_policy;
Things *kind of* work now for the default assignment operator generated by the compiler. I can now create a new item and then use the copy assignment(if they have the same storage policy). Things like... regular_grid <2,3> interp( f_values); //The default is the new non- const reference_policy. regular_grid <2,3> interp3 = interp; //Works! Also works for the copy_policy interp3 = interp; //Fails! Also fails for the copy_policy
Lower priority for me, but assignment will only work for 2 grids of type ref or 2 of type value. What is the best way to write the assignment operator to allow assignment between the different policy types? (combinations except assignment to a const_reference_policy of course)
template<int M1, int N1, class S> friend class regular_grid; regular_grid& operator=(const regular_grid& other) { axis_ = other.axis_ }; template<class S> regular_grid& operator=(const regular_grid<M, N, S>& other) { axis_ = other.axis_ }; In Christ, Steven Watanabe