Boost logo

Boost Users :

From: Stephen Gross (sgross_at_[hidden])
Date: 2005-09-12 09:25:49


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?

(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?

(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.
The code, however, fails to compile. Here's the code and error log:

=== CODE ===
template<typename T>
class foo
{
  BOOST_CLASS_REQUIRE3(T, int, const std::string &, boost,
UnaryFunctionConcept);
};
============

Produces the following error (from g++):

==== ERROR LOG ====
test.cpp:42: error: parse error before `::' token
test.cpp:42:80: pasting "&" and "UnaryFunctionConcept" does not give a valid
preprocessing token
test.cpp:42: error: parse error before `std'
test.cpp:42:80: pasting "&" and "UnaryFunctionConcept" does not give a valid
preprocessing token
test.cpp:42:80: pasting "&" and "UnaryFunctionConcept" does not give a valid
preprocessing token
test.cpp:42: error: missing ';' before right brace
test.cpp:42: confused by earlier errors, bailing out
===================

Is this a bug?

Thanks in advance for your thoughts,
--Steve

Stephen Gross
Case Western School of Medicine
Cleveland, OH

"By Grabthar's hammer, by the sons of Worvan, you shall be avenged." - Dr.
Lazarus


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