Boost logo

Boost Users :

From: Jeremy Siek (jeremy.siek_at_[hidden])
Date: 2005-09-12 10:19:00


Hi Stephan,

On Sep 12, 2005, at 9:25 AM, Stephen Gross wrote:
> I'm just now learning about the concept_check library and how Unary
> and
> BinaryFunctionConcepts work in it. I have a few questions:
>
> (1) The implementation of Unary and Binary (FunctionConcepts)
> assume that
> the return type is assignable ("r = f(arg)" tries to assign a value
> to r).
> But what if the return type is a reference? Won't the function
> concept fail
> to compile? Is this a bug?

That looks like a bug.

Here's a challenge for you: how would you fix this bug?

> (2) I'm implementing an NaryFunctionConcept for functors taking
> more than 2
> arguments. The BOOST_CLASS_REQUIREx macro, however, appears to be
> limited to
> 4 types. This limits the NaryFunctionConcept to functors with up to
> two
> arguments. Is there a way to expand the BOOST_CLASS_REQUIREx macro
> to handle
> more than 4 types?

I'm sure there is a way. Can you think of a way to do it? Perhaps the
boost
preprocessor library would help.

> (3) I ran into a compiler problem when using BOOST_CLASS_REQUIREx;
> when any
> of the type macros have spaces or non-alphanumeric characters in
> them, the
> compiler reports an error. In the following example, I try to use
> the macro
> to require a UnaryFunctor taking a const std::string & and
> returning an int.

Yes, you need to create a typedef for such types. This restriction
should
be documented. I've checked in a fix to the docs.

Thanks,
Jeremy


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