Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2007-05-23 14:07:36


Daniel Wallin wrote:
> This is unnecessarily inefficient. It's pretty easy to just use
> iterators, something like:
>
> template <class First, class Last, class F>
> bool do_until_impl(First, Last, F f)
> {
> boost::value_initialized<typename mpl::deref<First>::type> x;

Does this not require that mpl::deref<First>::type be default-constructable?
Presumably this is the first type in my type sequence, and since I'm
dynamic_casting to all types in the sequence, it's not unreasonable to assume
that the type I'm casting to may be abstract. Will this work if my sequence
consists of abstract types? And even if the type is concrete, I can't, in
general, know anything about constructing it, i.e., I can't know if it can be
value-constructed.

It's entirely possible that I'm missing something important here. I'd never
seen value_initialized before, and the documentation at
http://www.boost.org/libs/utility/value_init.htm is rather dense going.

> if (f(boost::get(x)))
> return true;

This is passing a runtime parameter to f, but what I want to pass to f is a
compile-time type -- the type to dynamically_cast to. The pointer I'm casting
is fixed, so I can bind it into f when I create f. Am I just missing something?

Thanks,

Scott


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net