Opened 12 years ago

Last modified 12 years ago

#4443 new Bugs

Bounded vector constructor missing explicit and an initialization version

Reported by: Jesse Perla <jesseperla@…> Owned by: Gunter
Milestone: Boost 1.44.0 Component: uBLAS
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

While vector<> has an 'explicit' on its constructor with unsigned integers, bounded_vector does not. This means the following ugliness compiles: bounded_vector<double, 2> v; v = 2; This SHOULDN'T compile if the patch is applied. Using cast to unsigned int.

Also, while vector<> has a constructor that takes a size and then a value to initialize with, bounded_vector does not. I added in a constructor for this operation and for consistency, so the following compiles: ublas::vector<double> v(2, 1.8); ublas::bounded_vector<double,2> v(2, 1.8); Now consistent.

.... this became necessary when I was doing programming for generic vector types and wanted to construct with an initial value.

Attachments (2)

bounded_vector_constructors.patch (654 bytes ) - added by Jesse Perla <jesseperla@…> 12 years ago.
test_boost_ublas_vector_constructors.cpp (770 bytes ) - added by Jesse Perla <jesseperla@…> 12 years ago.

Download all attachments as: .zip

Change History (3)

by Jesse Perla <jesseperla@…>, 12 years ago

by Jesse Perla <jesseperla@…>, 12 years ago

comment:1 by Jesse Perla <jesseperla@…>, 12 years ago

I have been porting some of my code to GCC and may have made a mistake on here. the value_type is not available here, so it should be added as a typdef in the bounded_vector class:

typedef typename vector_type::value_type value_type;

Also, gcc didn't like my begin() and end() in the constructor with fill, so try adding a this->begin() and this->end() instead. I am not sure the best way to do this.

Note: See TracTickets for help on using tickets.