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 news:40B57D2D.6070905_at_boost-consulting.com...
> | > 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 http://www.boost.org/libs/spirit/doc/stored_rule.html
> | 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;
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
identifier = ....
fileIdentifier = identifier; // an alias
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk