Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#5096 closed Bugs (fixed)

display_expr is noncopyable

Reported by: Christopher Schmidt 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.

Attachments (0)

Change History (4)

comment:1 Changed 7 years ago by Eric Niebler

Resolution: invalid
Status: newclosed

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

comment:2 Changed 7 years ago by Eric Niebler

Resolution: invalidfixed

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

comment:3 Changed 7 years ago by Christopher Schmidt

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.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Eric Niebler.
The resolution will be deleted.

Add Comment

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

Note: See TracTickets for help on using tickets.