|
Boost : |
From: Steven Watanabe (steven_at_[hidden])
Date: 2007-02-19 14:38:08
AMDG
David Abrahams <dave <at> boost-consulting.com> writes:
>
> Steven Watanabe <steven <at> providere-consulting.com> writes:
>
> > AMDG
> >
> > I am requesting a formal review of my switch_ function template.
> > The implementation docs and tests are available in the vault.
> > http://tinyurl.com/yvssgx
>
> Should this be part of a more general metaprogramming library
> containing "runtime construct generators?" I can imagine such
> generators as overload_set, while_loop, if_statement...
>
What would overload_set do?
while_loop. Is this what you had in mind?
template<bool>
struct while_impl;
template<>
struct while_impl<true> {
template<class Condition, class F, class T>
struct apply {
typedef typename F::template result<T>::type result;
typedef typename while_impl<
mpl::apply<Condition, result>::type::value
>::template apply<Condition, F, result> next;
typedef typename next::type type;
static type value(F f, T& t) {
result r(f(t));
return(next::value(f, r));
}
};
};
template<>
struct while_impl<false> {
template<class Condition, class F, class T>
struct apply {
typedef T type;
static type value(F, T& t) {
return(t);
}
};
};
I can't think of any use for if_statement that
isn't easier using if.
mpl::for_each already handles looping over a sequence.
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk