Re: [eigen] A question for MSVC experts

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi Gael,

Short answer: To avoid the class breaking code expecting a std::vector

Long answer: The STL standard defines three overloaded insert() methods:

iterator insert ( iterator position, const T& x );
    void insert ( iterator position, size_type n, const T& x );
template <class InputIterator>
    void insert ( iterator position, InputIterator first, InputIterator last );

( http://www.cplusplus.com/reference/stl/vector/insert/ )

and since if one defines a method in a derived class with the same
name than in the base class the former "shadows" all other overloads,
all the overloaded versions must be defined again in the derived class
to make them visible.


Now, what should be investigated is the actual reason of the error and
fix it! ;-)
At first sight I don't see the problem. Could you try leaving those
two lines just as:

using vector_base::insert;
 iterator insert(const_iterator position, const value_type& x);
 void insert(const_iterator position, size_type new_size, const value_type& x);

to discard the problem is the methods implementation and not their declaration??

JL

On Tue, Jun 14, 2011 at 9:05 PM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> Hi,
>
> in StdVector.h, for MSVC we have the following lines:
>
>  using vector_base::insert;
>  iterator insert(const_iterator position, const value_type& x)
>  { return vector_base::insert(position,x); }
>  void insert(const_iterator position, size_type new_size, const value_type& x)
>  { vector_base::insert(position, new_size, x); }
>
> On win32 builds this seems to produce compilation errors like:
>
> "2 overloads have similar conversions"
>
> Actually, I don't really understand the purpose of these two overloads
> of insert(). Same for push_back which is simply implemented as:
>
> void push_back(const value_type& x)
> { vector_base::push_back(x); }
>
> According to this thread:
> http://forum.kde.org/viewtopic.php?f=74&t=95499 removing these lines
> fix the issue and does not introduce new errors.
>
> So does anybody remember what was their purpose?
>
> Gael
>
>
>



-- 
___________________________________________________________

Dr. Jose-Luis Blanco-Claraco
Dpt. Ing. Civil, Mat. y Fabric - Phone: +34 951 952435
E.T.S.I. Industriales - Despacho 2.037
Universidad de Malaga - Campus Universitario de Teatinos
29071 Malaga, Spain
https://sites.google.com/site/jlblancosite/
___________________________________________________________



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/