Opened 11 years ago

Last modified 6 years ago

#6026 assigned Bugs

phoenix block statement tries to copy objects instead of references

Reported by: armagvvg@… Owned by: Kohei Takahashi
Milestone: To Be Determined Component: phoenix
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

Let's use a simplest class, that can't be copied:

class A {
   A() {}
   A(const A&);
public:
   static A* construct() { return new A(); }
   const A& operator<<(const char *p) const { return *this; }
};

A *pa = A::construct();
A &a = *pa;

The code which use this object one time normally works:

(boost::phoenix::ref(a) << boost::phoenix::placeholders::_1)("aaa");

But when I try to use this object two times, I get an error:

(
   boost::phoenix::ref(a) << boost::phoenix::placeholders::_1
   ,boost::phoenix::ref(a) << boost::phoenix::placeholders::_1
)("aaa");

Result: 'A::A' : cannot access private member declared in class 'A'

Expecting: pass compilation and invoke "A::operator<<" two times.

Note: preprocessing directive "BOOST_SPIRIT_USE_PHOENIX_V3" was defined.

Change History (1)

comment:1 by Kohei Takahashi, 6 years ago

Owner: changed from Thomas Heller to Kohei Takahashi
Status: newassigned
Note: See TracTickets for help on using tickets.