Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Strange behavior with semantic action and custom tag function
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2008-10-11 12:22:42


Eric Niebler a écrit :
> <snip very beautifully written transform>
>
I take this as a compliment :D
> Could you post the code? The problem is probably pretty simple.
The complete code ? Wow, it may end up rather large. I'll pack it in
some archive
of only the DSL related part and attach it to this mail. It won't be
compilable though
as it has large roots into a even larger project.
> It's true, with make_expr you can create expressions that don't
> conform to the grammar for your domain. But a call to make_expr is
> pretty explicit -- it can't happen by accident. And make_expr is to be
> used by DSEL designers such as yourself who may use it to build an
> expression template piecemeal ... the intermediate pieces of which may
> not conform to the grammar, while the whole might. Does that make sense?
I see. So it's my responsibility to write correct make_expr code then to
SFINAE them out if I need it.
The current problem arise with a simple complex number DSL I'm writing
as an introductory example
for a master degree 'Generic Programming in C++' lesson I'm building up.
I have a conj_ tag which
represents taking the conjugate of a complex number.

The function itself is :

  template<class X>
  typename proto::result_of::make_expr<conj_, complex_domain,X const
&>::type
  conj( X const& x )
  {
    return proto::make_expr<conj_,complex_domain>(boost::cref(x));
  }

this works but if I write stupid code like :

z = conj("lol");

I got a large message telling me char* const don't have w/e properties
THEN a 'no such function conj(char* const)'
If I add a small enable_if using matches over X, it works as I want it.

So if I understand correctly, this is the intended behavior and I have
to SFINAE stuff out.

___________________________________________
Joel Falcou - Assistant Professor
PARALL Team - LRI - Universite Paris Sud XI
Tel : (+33)1 69 15 66 35


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