Modify

Ticket #5096 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 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:

Description

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

Change History

comment:1 Changed 3 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 3 years ago by eric_niebler

  • Resolution changed from invalid to fixed

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

comment:3 Changed 3 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.

 https://github.com/ryppl/boost-svn/blob/fad63fe4389e8a46e8ea9183eae46e401ea4bb6f/boost/fusion/algorithm/iteration/for_each.hpp http://www.boost.org/doc/libs/1_45_0/libs/fusion/doc/html/fusion/algorithm/iteration/functions/for_each.html

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 3 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.

View

Add a comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.