|
Proto : |
Subject: Re: [proto] Using a derived class as terminals in Boost.proto
From: Frank Winter (fwinter_at_[hidden])
Date: 2016-04-14 10:37:47
On 04/14/2016 10:10 AM, Mathias Gaunard wrote:
> On 14 April 2016 at 14:43, Frank Winter <fwinter_at_[hidden]
> <mailto:fwinter_at_[hidden]>> 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<typename T>
> struct IsVector
> : mpl::false_
> {};
>
>
> template<>
> struct IsVector< Vector >
> : mpl::true_
> {};
>
>
> Surely this should be true for all types derived from Vector.
>
> template<typename T, typename Enable = void>
> struct IsVector
> : mpl::false_
> {};
>
> template<typename T>
> struct IsVector<T, typanem enable_if< is_base_of<Vector, T> >::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<typename T, typename Enable = void >
struct IsVector
: mpl::false_
{};
template<typename T>
struct IsVector<T , typename std::enable_if< std::is_base_of<Vector,
T>::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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/proto
>
Proto list run by eric at boostpro.com