Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-11-20 00:35:48


> >>template<class T> void f( const T&) {}
> >>template<class T> void f( T&) {}
> >>const std::deque<int> d;
> >>f(d); // compile-time error in VC6
> >
> >
> > true. that's why the collection traits allows you to remedy this.
> > You simply provide one function wuth a T& argument and
> > use some metaprogramming to figure out the rest. You do loose the
> > probability to use rvalues, but vc6 users just have to accept that.
>
> The point is that this can be remedied like this:
>
> #ifndef BOOST_VC6_WORKAROUND
> template<class T> void f( const T&) {}
> #endif
> template<class T> void f( T&) {}
>
> for it to work correctly for VC6.

this is not enough in my case since the return type might depend
on the constness of the argument.

> > erase_range( m_snapshots, make_iterator_range( unique( m_snapshots,
> > snapshot_eq_time ), m_snapshots.end() ) );
> >
>
> indeed, but quite a few more keys to type;)
> redundant also
>
> > which could certainly be better. Maybe we need an erase_from(),
erase_util()
> > took a single iterator?
>
> I'm not sure I understand...

> > erase_from( c, std::unique( c ) ); erase from the iterator to the end
> > erase_to( c, std::unique( c ) ); erase from the beginnning to the
iterator

> >>// taken from real-life code
> >>if ( get_account_history().pending_orders().find( order_id) !=
> >>get_account_history().pending_orders().end() )
> >
> >
> > seriously, you're joking right? I would definitely make a temporary or
> > make a function that gave me the pending_orders. real life should never
be
>
> Only for one question? (an if)
>
> > more complicated than
> >
> > order_t orders = ...;
> > if( orders.find( order_id ) != orders.end() )
> >
> > if it is, something else is wrong and a refactoring needs to be done.
>
> I'm not sure about this. You're highly optimistic in this matter;)

come on :-) x().y().z().t().u().v() is not a very good
abstraction. even x().y() is suspicious since we need to evaluate it twice.
I've only read one book about refacoring by Martin Fowler, but it's ok.

> >
> > Please imagine
> >
> // missing typedef ;)
> > order_t orders = get_account_history().pending_orders();
> > some_range_class r( boost::find_if( orders, pred), orders.end() );

Oh yeah, I assumed it was already there. It certainly should be there
somewhere instead of hardcoding
container<X> and container<X>::iterator all over the place.

> >[...]
> > not an operator bool(), but something convertible to bool (like a
pointer to
> > a member) to prohibit misuse.
> fair enough. But will this compile:
> if ( r1 && r2) ... // r1 and r2 are ranges
>
AFAICT no. btw, it could be implemented like

  typedef iterator (basic_substring::* safe_bool)();
 operator safe_bool() const
 {
      return empty() ? 0 : &basic_substring::end;
 }

-Thorsten


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