Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-04-02 18:36:18


On Wed, Apr 2, 2008 at 11:59 PM, shunsuke <pstade.mb_at_[hidden]> wrote:
> Giovanni Piero Deretta wrote:
> > Hum, if you want to have guaranteed static initialization, you need to
> > statically know the function pointer value:
> >
> > template<typename Sig, Sig * p>
> > static_function_ptr {
> > typedef typename result_of_sig<Sig>::type result_type;
> >
> > template<typename Args...>
> > result_type operator()(Args.... args) {
> > return p(args);
> > }
> > };
> >
> > Substitute the pseudo-variadic syntax with proper preprocessor magic :).
>
> Egg secretly has the feature.
> See "egg/inlined.hpp".
>

Inline because it is practically the only way to get gcc to inline a
function pointer :) ?

Anyways, one reason less to need complex static initialization.

>
> >> I'm really afraid that those macros may keep users away from the library.
> >>
> >
> > Hey, maybe it is just me, maybe others won't have any problems with
> > them. I just find the macro based initialization ugly and unnecessary
> > complex.
>
> You expect something like this?:
>
> static_result_of<T_curry2(F)>::type c = BOOST_EGG_CURRY2({}); // static

Can't you use boost::result_of here? (or return_of)
Also, do you have a plan for allowing complex statically initialized
expressions in header files
without ODR violations?

> boost::result_of<T_curry2(F const &)>::type c = curry2(f); // dynamic

or egg::return_of if you want recursive evaluation.

> stateless_result_of<T_curry2(F)>::type c = BOOST_EGG_STATELESS(); // for stateless one.

Why not:

   expression<T_curry2(F)> c = { /*just this please :) */ }; // note
the missing ::type

-- 
gpd

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