Opened 11 years ago

Closed 3 years ago

#474 closed request (fixed)

create Vector from temporary VectorView fails

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.15
Component: utility Version: trunk
Keywords: Cc:

Description

This code does not compile

	utility::Matrix m(10,3);
	utility::Vector v2(m.row_view(1));

Change History (18)

comment:1 Changed 11 years ago by Peter

Milestone: yat 0.5
Resolution: wontfix
Status: newclosed

Hm, this is a documented weakness. Use

utility::Matrix m(10,3);
utility::Vector v2(m.row_view(1));

to achieve the desired result.

comment:2 Changed 11 years ago by Peter

I meant

utility::Matrix m(10,3);
utility::Vector v2(m.row_const_view(1));

comment:3 Changed 11 years ago by Peter

Milestone: yat 0.x+
Resolution: wontfix
Status: closedreopened

Similarily:

Matrix result(10,10, 0.0);
Matrix m(10,10, 1.0);
utility::VectorView vv=result.column_view(2);
vv=m.column_view(3); 

does not compile. Likewise to mentioned above a workaround would be

Matrix result(10,10, 0.0);
Matrix m(10,10, 1.0);
utility::VectorView vv=result.column_view(2);
vv=m.column_const_view(3); 

This ticket should not be closed though because it is a severe weakness.

comment:4 Changed 11 years ago by Peter

Status: reopenednew

This problem could be avoided with the new rvalue semantics that will be included in the C++0x standard as described here.

This feature is included in gcc 4.3, so one could solve this for users using gcc 4.3 or later, but since I'm sitting with 4.1 I won't be able to implement that in the near future. Also, I'm not sure it's wise to fork the library like that.

comment:5 Changed 11 years ago by Peter

comment:6 Changed 11 years ago by Peter

(In [1720]) adding some tests that refs #474. The commented code should compile before closing this ticket

comment:7 Changed 11 years ago by Peter

Having this working, we should perhaps add implicit conversion from VectorView? to VectorConstView? (as discussed in #467).

comment:8 Changed 7 years ago by Peter

Boost.Move provides macros to write move construction/assignment for both c++03 and c++11 compilers.

comment:9 Changed 7 years ago by Peter

Milestone: yat 0.x+yat 0.10

I suggest we implement move construction/assignment for at least Matrix and Vector classes.

comment:10 Changed 7 years ago by Peter

Status: newassigned

comment:11 Changed 7 years ago by Peter

Milestone: yat 0.10yat 0.x+
Status: assignednew
Type: defectrequest

Boost.Move was introduced in boost-1.48 which was released 2011-11-15. I'm reluctant to introducing a dependency to such as recent version. Both RHEL6 and CentOS6, for example, distribute Boost-1.41.

comment:12 Changed 7 years ago by Peter

It struck me that we could implement this conditionally i.e. only implement if boost 1.48 (or newer) is available. One could also implement if compiler is modern enough. Or combine these option in:

#if this
do this
#elif that
do that
#else
do nothing
#endif

Not sure in which order to pick things, but my gut feeling is that one should implement clean without boost if compiler supports it, otherwise use boost if boost is available, else skip. Note, that boost itself does some selection based on used compiler.

comment:13 Changed 3 years ago by Peter

It is perhaps time to upgrade required boost version, so we can look at this.

comment:14 Changed 3 years ago by Peter

(In [3587]) move constructor for vector; refs #878 and #474

comment:15 Changed 3 years ago by Peter

Milestone: yat 0.x+yat 0.15

comment:16 Changed 3 years ago by Peter

Test code added in r1720 compiles with GCC 4.8.5 in c++98 mode.

comment:17 Changed 3 years ago by Peter

(In [3594]) uncomment test code that used to be problematic. refs #474

comment:18 Changed 3 years ago by Peter

Resolution: fixed
Status: newclosed

(In [3595]) implicit conversion from VectorView? to VectorConstView?. closes #474

Note: See TracTickets for help on using tickets.