Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2008-01-04 05:56:53


Alexander Nasonov <alnsn <at> yandex.ru> writes:
> BTW,
> switch_ doesn't implement fall-though and I was worried about performance of
> this important case (bzero with Duff's device optimization):

Sorry for typos and errors in code. Assembly are not identical but close.
If I change modern_duff to throw from switch_, it would change assembly
completely event though the compiler can deduce from n % 8 that all cases
are covered.
So, throwing is good for protecting programmers from accidental errors
but not good for code generation.

I wonder why don't you use none_t or even a special default_t?

struct some_func {
    typedef void result_type;
    template<class Case>
    void operator()(Case c) const {
        std::cout << c << std::endl;
    }

    void operator()(default_t) const {
        throw out_of_range();
    }
};

Though, it may break passing a lambda expression to switch_ but
this case probably is not supported because IIRC there is no
result_type in lambda expression types.

--
Alexander

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