Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2004-05-27 01:44:57

Thorsten Ottosen wrote:

> Hi Joel,
> "Joel de Guzman" <joel_at_[hidden]> wrote in message
> | > 2. if we shouldn't copy a rule, why is copying not disabled? It has been a source of errors in my code that
> | > I forgot & on my return value.
> |
> | I believe
> | answers this question.
> "The rule is a wierd C++ citizen, unlike any other C++ object. It does not have the proper copy and assignment semantics and cannot
> be stored and passed around by value. You cannot store rules in STL containers (vector, stack, etc) for later use and you cannot
> pass and return rules to and from functions by value."
> I have read this page before, but I still don't get why the rule has copy and assignment semantics at all.
> Afterall, you admit copying and assignment does not make sense, yet it is still defined :-) What am I overlooking? Why do we need
> the current
> copy/assignment semantics?

Copy and assignment does not make sense. However, the = makes sense,
yet, not in the C++ sense.


     rule<> a = x;


     rule<> a;
     a = x;

How should this behave if x is an int_p? Now how should it behave if
x is another rule? Consider a concrete example (snipped from the pascal

     rule<> identifier;
     rule<> fileIdentifier;

     identifier = ....

     fileIdentifier = identifier; // an alias

Joel de Guzman

Boost list run by bdawes at, gregod at, cpdaniel at, john at