Boost logo

Boost Users :

From: Scott Meyers (usenet_at_[hidden])
Date: 2006-03-10 15:07:03


If I invoke apply_visitor, what is the time complexity wrt the number of types
that may be in the variant? The doc doesn't seem to address this. I looked at
the source code, but all I can remember before my head exploded due to exposure
to the MPL and the PPL was "switch" (which suggests constant time) and
"unrolling" which suggests either linear or constant time, depending on what is
being unrolled. Does anybody know what the time complexity of apply_visitor is?

My real question is whether applying a visitor to a variant is more efficient
than a cascading series of calls to get. I know that the following runs in
linear time wrt the number of types in the variant,

   if (T1 *p = get<T1>(&myVariant)) ...
   else if (T2 *p = get<T2>(&myVariant)) ...
   else ...
   else if (Tn *p = get<Tn>(&myVariant)) ...

but what about this?

   apply_visitor(myVisitor, myVariant);

Thanks for any enlightenment.

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