Re: [proto] Using a derived class as terminals in Boost.proto

2016-04-14 Thread Eric Niebler
Proto grammars and transforms handle this better than evaluators, which are
deprecated. It would pay to look into some examples that use transforms.
Sorry, that's all the advice I have time for at the moment.

\e
On Apr 14, 2016 10:33 AM, "Mathias Gaunard" 
wrote:

> I'd try to use IsVector.
> I'm not sure how to do this with a grammar (maybe someone can pitch in)
> but you could do something like this
>
> enable_if< IsVector::type> >
>
> On 14 April 2016 at 18:04, Frank Winter  wrote:
>
>> I made some progress. If I specialize struct VectorSubscriptCtx::eval
>> with Vector10, like
>>
>>
>> struct VectorSubscriptCtx
>> {
>> VectorSubscriptCtx(std::size_t i) : i_(i) {}
>>
>> template
>> struct eval
>> : proto::default_eval
>> {};
>>
>> template
>> struct eval<
>> Expr
>> , typename boost::enable_if<
>> proto::matches >
>> >::type
>> >
>> {
>> //..
>> }
>> };
>>
>> then it works (is was specialized with Vector). It also works when using
>> the Boost _ literal (match anything), like
>>
>> template
>> struct eval<
>> Expr
>> , typename boost::enable_if<
>> proto::matches >
>> >::type
>>
>>
>> However, I feel this is not good style. Can this be expressed with the
>> is_base_of trait instead?
>>
>>
>>
>>
>>
>> On 04/14/2016 10:10 AM, Mathias Gaunard wrote:
>>
>>> On 14 April 2016 at 14:43, Frank Winter >> > wrote:
>>>
>>> Hi all!
>>>
>>> Suppose you'd want to implement a simple EDSL (Embedded Domain
>>> Specific Language) with Boost.proto with the following requirements:
>>>
>>>  Custom class 'Vector' as terminal
>>>  Classes derived from 'Vector' are working terminals too, e.g.
>>> Vector10
>>>
>>> [...]
>>>
>>> template
>>> struct IsVector
>>>: mpl::false_
>>> {};
>>>
>>>
>>> template<>
>>> struct IsVector< Vector >
>>>: mpl::true_
>>> {};
>>>
>>>
>>> Surely this should be true for all types derived from Vector.
>>>
>>> template
>>> struct IsVector
>>>: mpl::false_
>>> {};
>>>
>>> template
>>> struct IsVector >::type>
>>>: mpl::true_
>>> {};
>>>
>>>
>>> ___
>>> proto mailing list
>>> proto@lists.boost.org
>>> http://lists.boost.org/mailman/listinfo.cgi/proto
>>>
>>>
>>
>> ___
>> proto mailing list
>> proto@lists.boost.org
>> http://lists.boost.org/mailman/listinfo.cgi/proto
>>
>
>
> ___
> proto mailing list
> proto@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/proto
>
>
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Using a derived class as terminals in Boost.proto

2016-04-14 Thread Mathias Gaunard
On 14 April 2016 at 15:37, Frank Winter  wrote:

>
> and still, I get basically the same error message:
>
> /home/fwinter/src/boost_1_60_0/boost/proto/context/default.hpp:121:41:
> error: no match for ‘operator+’ (operand types are ‘Vector10’ and
> ‘Vector10’)
>  BOOST_PROTO_BINARY_DEFAULT_EVAL(+, proto::tag::plus, make, make)
>
>
> It's weird since the operator+ should be there for Vector, and since I am
> importing the namespace VectorOps, it should work for derived classes. I
> don't see why it's not working.


A recent enough compiler should tell you which candidates it tried and why
they were removed due to SFINAE.
I don't have the time to try out your code at the moment but I recommend
you try to take a look at this.
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Using a derived class as terminals in Boost.proto

2016-04-14 Thread Frank Winter



On 04/14/2016 10:10 AM, Mathias Gaunard wrote:

On 14 April 2016 at 14:43, Frank Winter > wrote:

Hi all!

Suppose you'd want to implement a simple EDSL (Embedded Domain
Specific Language) with Boost.proto with the following requirements:

 Custom class 'Vector' as terminal
 Classes derived from 'Vector' are working terminals too, e.g.
Vector10

[...]

template
struct IsVector
   : mpl::false_
{};


template<>
struct IsVector< Vector >
   : mpl::true_
{};


Surely this should be true for all types derived from Vector.

template
struct IsVector
   : mpl::false_
{};

template
struct IsVector >::type>
   : mpl::true_
{};




I had tried this


template<>
struct IsVector< Vector10 >
  : mpl::true_
{};


before. Same error message. Now I tried the base_of implementation


template
struct IsVector
  : mpl::false_
{};

template
struct IsVectorT>::value >::type>

  : mpl::true_
{};


and still, I get basically the same error message:

/home/fwinter/src/boost_1_60_0/boost/proto/context/default.hpp:121:41: 
error: no match for ‘operator+’ (operand types are ‘Vector10’ and 
‘Vector10’)

 BOOST_PROTO_BINARY_DEFAULT_EVAL(+, proto::tag::plus, make, make)


It's weird since the operator+ should be there for Vector, and since I 
am importing the namespace VectorOps, it should work for derived 
classes. I don't see why it's not working.


Thanks,
Frank




___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto



___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Using a derived class as terminals in Boost.proto

2016-04-14 Thread Mathias Gaunard
On 14 April 2016 at 14:43, Frank Winter  wrote:

> Hi all!
>
> Suppose you'd want to implement a simple EDSL (Embedded Domain Specific
> Language) with Boost.proto with the following requirements:
>
> Custom class 'Vector' as terminal
> Classes derived from 'Vector' are working terminals too, e.g. Vector10
>
> [...]

template
> struct IsVector
>   : mpl::false_
> {};
>
>
> template<>
> struct IsVector< Vector >
>   : mpl::true_
> {};
>
>
Surely this should be true for all types derived from Vector.

template
struct IsVector
  : mpl::false_
{};

template
struct IsVector >::type>
  : mpl::true_
{};
___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto


Re: [proto] Using a derived class as terminals in Boost.proto

2016-04-14 Thread

___
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto