Opened 12 years ago

Closed 12 years ago

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

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.

Change History (4)

comment:1 by Eric Niebler, 12 years ago

Resolution: invalid
Status: newclosed

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

comment:2 by Eric Niebler, 12 years ago

Resolution: invalidfixed

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

comment:3 by Christopher Schmidt, 12 years ago

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 by Eric Niebler, 12 years ago

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.

Note: See TracTickets for help on using tickets.