Boost logo

Boost :

Subject: Re: [boost] Boost.Conversion: functors namming
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-05-25 08:43:04


On Wed, May 25, 2011 at 2:28 PM, Vicente Botet <vicente.botet_at_[hidden]> wrote:
>
> Vicente Botet wrote:
>>
>>
>> Thomas Heller-7 wrote:
>>>
>>> On Wed, May 25, 2011 at 10:44 AM, Vicente Botet
>>> &lt;vicente.botet_at_[hidden]&gt; wrote:
>>>>
>>>
>>>> Hi,
>>>>
>>>> this independent overloading could be done if there was a class
>>>> placeholder,
>>>> but in Phoenix a placeholder is a concept, isn't it. So the overloading
>>>> can
>>>> be done only using SFINAE, which implies that one overload works for T
>>>> that
>>>> are placeholders and the otherfor T that are no placeholders.
>>>>
>>>> Let me know if I'm missing something.
>>>
>>> FWIW, a phoenix actor is a concept, yes. The file
>>> boost/phoenix/core/is_actor.hpp
>>> has only a dependency on the boost/mpl/bool.hpp header. So including this
>>> might
>>> not really add to much dependency on your code.
>>>
>>> Another possibility certainly is to create your own trait:
>>>
>>> template <typename T, typename Enable>
>>> struct enable_functor : mpl::false_ {};
>>>
>>> or something, that gets specialized on phoenix::is_actor once your
>>> user includes the
>>> header that enables functors. Using this, you gain another point of
>>> flexibility by being able
>>> to support other functional style libraries.
>>>
>>>
>>
>> Thanks for your clever suggestion. I will adopt it.
>>
>>
>
> Well it seems it is to clever to me. I don't reach to specialize
> enable_functor for a T satisfying phoenix::is_actor. BTW,what is the Enabled
> parameter for? How this metafunction could be used?
>
> Any help would appreciated.

The Enable template parameter was exactly to specialize for phoenix actors ;)

template <typename T, typename Enable = void>
struct is_lazy
    : mpl::false_
{};

template <typename T>
struct is_lazy<T, typename enable_if<is_actor<T> >::type >
    : mpl::true_
{};

HTH,
Thomas


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