Boost logo

Boost Users :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2004-12-26 14:08:27


"Andy Little" <andy_at_[hidden]> wrote

> I'm guessing that template parameters are a no-go. OTOH can I register
the
> following:
>
> template <
> typename A,
> template <typename> class Op,
> typename B,
> typename Enable = void
> >
> struct binary_operation;
>
> (Basically I am not able to compile and wonder if this may be the issue) .

Yes, unfortunately we only support type and integral template parameters,
but not template template parameters :-( Supporting template template
parameters just looks impossible to me, since templates can't be returned
from metafunctions (you can't typedef them).

OTOH, if you are willing to change your interface just a little, and just
use a wrapper over your operation, something like this:

struct plus_identity
{
    template<class A, class B> struct apply : plus<A, B>{}:
};

(pass plus_identity, and use Op::template apply<A, B> instead of Op<A, B>)

then your template would accept a simple type parameter rather than a
template template parameter, and would be fully compatible with the
BOOST_TYPEOF system.

The drawback -- the code need to be changed to cooperate with the
BOOST_TYPEOF system;

The benefit -- you have a portable typeof right now, long time before it is
in the standard, and even longer time before it's implemented by most major
vendors. Also we use native typeof when possible, so on those compilers
that do implement it there is no compile-time performance penalty.

Regards,

Arkadiy


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