Boost logo

Boost :

Subject: Re: [boost] Phoenix review
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-09-26 13:24:58


Giovanni Piero Deretta wrote:

> Instead of:
>
> switch_(arg1)
> [
> case_<1>(cout << val("one") << '\n'),
> case_<2>(cout << val("two") << '\n'),
> default_(cout << val("other value") << '\n')
> ]
>
> do this:
>
> switch_(arg1)
> [
> case(1)[cout << val("one") << '\n'],
> case(2)[cout << val("two") << '\n'],
> default_[cout << val("other value"] << '\n')
> ]
>
> this allows not only runtime selection of switch case values, but it
> will also work with everything that is equally comparable:
>
> switch_(arg1)
> [
> case("one")[cout << val(1) << '\n'],
> case("two")[cout << val(2) << '\n'],
> default_[cout << val("other value"] << '\n')
> ]
>
> which IMHO is a killer feature.

In efficiency, you mean?
One dispatch is 0(1) in the number of cases, the other is 0(n).


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