Ticket #5096 (closed Bugs: fixed)

Opened 6 years ago

Last modified 6 years ago

display_expr is noncopyable

Reported by: cschmidt Owned by: eric_niebler
Milestone: To Be Determined Component: proto
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:


proto::functional::display_expr is not copyable. This can trigger hard errors inside Fusion when being passed to fusion::for_each as a functor because Fusion may expect functors to be copyable.


Change History

comment:1 Changed 6 years ago by eric_niebler

  • Status changed from new to closed
  • Resolution set to invalid

It's noncopyable by design. This function object maintains state. Using copies will give erratic results.

comment:2 Changed 6 years ago by eric_niebler

  • Resolution changed from invalid to fixed

(In [68314]) display_expr is copyable, fixes #5096

comment:3 Changed 6 years ago by cschmidt

Strictly speaking, [68314] defers the problem to detail::display_expr_impl, which is passed to fusion::for_each in display_expr_impl::impl although it is noncopyable. This is fine for now as Fusion passes around functors by const reference although the documentation states the opposite.

AFAIK Fusion's current implementation is plain wrong. Functors should never be passed around by const reference. IIRC that's due to a defect in C++98.

Anyway, wontfix/invalid is fine for me for now. I will try to propose a patch for fusion that removes const/reference qualifiers on functors and adds support for reference wrappers.

comment:4 Changed 6 years ago by eric_niebler

Ah, I see. I overlooked that fact that display_expr_impl was invoking fusion::for_each. Well, that's an internal detail of display_expr and can be easily changed. At least my change benefits others who want to pass disply_expr around by value.


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.