Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2004-09-21 08:53:38


The attached fix makes all tests compile for msvc (not
all run, though) and hopefully also for the other two toolsets
(can't try myself.) Two changes applied, both in
list_insert.hpp:

1. MSVC++ 6.0/7.0, in the presence of a templated
memfuns, interprets additional overloads as if they were
specializations of the former (which is not legal C++,
AFAIK). This introduces problems with the copy ctors
of list_insert, which can be workarounded by
  a) making the template copy ctor accept const references
  b) declaring and defining the plain default copy ctor of
  list_insert *after* the templated copy ctor.

2. list_insert::operator()(T t) has been changed to accept
a const reference instead.

With these changes, all tests build, though three of them
crash at run-time (list_inserter, list_of and multi_index_container)

I've checked the changes with a compiler other than MSVC
(GCC 3.2), seems like nothing ain't broken.

I've got two questions:

1. Could somebody (the author, I guess) validate these changes
for commit?
2. list_inserter follows a strange convention (IMHO) of not
forcing template params to be const references in its various
copy ctors and assignment operators, for instance:

list_inserter( Function fun );
template< class T >
list_inserter& operator=( T r );

Any reason for this approach? I don't know if this can pose
problems, but to me having these qualified with const & seems
like the usual way.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

164c164
<

---
> 
168,170d167
<         list_inserter( const list_inserter& r ) : insert_( r.insert_ )
<         {}
<         
172c169
<         list_inserter( list_inserter<Function2,Arg> r ) 
---
>         list_inserter( const list_inserter<Function2,Arg>& r ) 
175a173,175
>         list_inserter( const list_inserter& r ) : insert_( r.insert_ )
>         {}
>         
239c239
<         list_inserter& operator()( T t )
---
>         list_inserter& operator()( const T& t )

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk