Boost logo

Boost Users :

Subject: Re: [Boost-users] [lambda] extending lambda functions
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-24 11:48:17


AMDG

alfC wrote:
>> result is a template, so you just need to specialize it or use
>> some kind of metaprogramming (for instance Boost.Typeof).
>>
>
> Do you mean that I should do something like (not tested)::
> template<class R>
> struct norm_impl{
> template <typename Arg>
> struct result{
> typedef R type;
> };
> template <typename Arg>
> typename result<Arg>::type operator()(Arg ar1) const{
> return std::norm(ar1);
> }
> };
> template<class R> struct norm{
> static(???) phoenix::function<norm_impl<R> > func;
> };
> and use norm<double>::func (instead of norm_);
>
> How Boost.TypeOf fits in this or other approach?
>
>

No. I meant something like this:

struct norm_impl {
    template<typename Arg>
    struct result {
        typedef Arg type;
    };
    template<typename T>
    struct result<std::complex<T> > {
        typedef T type;
    };
    //...
};

Using Boost.Typeof result could be

template<class Arg>
struct result {
    BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (std::norm(Arg())));
    typedef typename nested::type type;
};

>>> 2) I may be asking for too much sugar but is there a way to name the
>>> function "std::norm" and not have conflicts with the standard
>>> "std::norm<T>(std::complex<T> const& c)", the best I could do was to
>>> call it std::norm_;
>>>
>> You're not allowed to put it in namespace std at all.
>>
>
> Obviously there is a mapping between standard functions and lazy
> functions (in Phoenix for example), Is there a way to express this
> mapping in their names?
>

Just put them in your own namespace.
The ones defined by phoenix are in namespace
boost::phoenix for instance.

In Christ,
Steven Watanabe


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