Opened 11 years ago
Last modified 6 years ago
#6026 assigned Bugs
phoenix block statement tries to copy objects instead of references
Reported by: | 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.
Note:
See TracTickets
for help on using tickets.
Confirmed in C++03 mode. http://melpon.org/wandbox/permlink/UZtPeYVO11Ad3EG3
In C++11, it works: http://melpon.org/wandbox/permlink/x6k6rOMUbepDgkBh