Opened 12 years ago

Closed 12 years ago

#4910 closed Patches (fixed)

ambiguity of operator<< in display_expr

Reported by: Maxim Yanchenko <Maxim.Yanchenko@…> Owned by: Eric Niebler
Milestone: To Be Determined Component: proto
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

from here: http://cpp-next.com/archive/2010/09/expressive-c-playing-with-syntax/comment-page-1/#comment-1134

struct A {};
struct B:A {};
std::ostream& operator<<( std::ostream& out, const A& ) { return out << "this is A!"; }

If you do

proto::display_expr( map( A(), 1 ) );

it works, but if you do

proto::display_expr( map( B(), 1 ) );

it doesn't compile due to ambiguity introduced by hidden_detail_::operator<< that does this nice typeid output.

The patch for boost/proto/debug.hpp against 1.44.0 (works for me) and last revision 66440 (not tried to compile, just by analogy) is attached.

Attachments (4)

display_expr-1.44.0.patch (2.8 KB ) - added by Maxim Yanchenko <Maxim.Yanchenko@…> 12 years ago.
patch against 1.44.0
display_expr-66440.patch (2.8 KB ) - added by Maxim Yanchenko <Maxim.Yanchenko@…> 12 years ago.
patch against rev. 66440
display_expr-1.44.0.2.patch (3.0 KB ) - added by Maxim Yanchenko <Maxim.Yanchenko@…> 12 years ago.
patch against 1.44.0
display_expr-66440.2.patch (3.1 KB ) - added by Maxim Yanchenko <Maxim.Yanchenko@…> 12 years ago.
patch against rev. 66440

Download all attachments as: .zip

Change History (9)

by Maxim Yanchenko <Maxim.Yanchenko@…>, 12 years ago

Attachment: display_expr-1.44.0.patch added

patch against 1.44.0

by Maxim Yanchenko <Maxim.Yanchenko@…>, 12 years ago

Attachment: display_expr-66440.patch added

patch against rev. 66440

by Maxim Yanchenko <Maxim.Yanchenko@…>, 12 years ago

Attachment: display_expr-1.44.0.2.patch added

patch against 1.44.0

by Maxim Yanchenko <Maxim.Yanchenko@…>, 12 years ago

Attachment: display_expr-66440.2.patch added

patch against rev. 66440

comment:1 by Maxim Yanchenko <Maxim.Yanchenko@…>, 12 years ago

The patches <xxx>.2.patch are slightly simpler and cleaner than the first submitted (can't delete them myself, so please feel free to delete). There is a self-written has_ostream_shift<T> trait, not sure if we already have one in Boost. If so, please feel free to replace with the blessed one.

comment:2 by Eric Niebler, 12 years ago

Attempted fix in [67366]. Let's see how the new display_expr tests fare on trunk.

comment:3 by Peter Schüller <schueller.p@…>, 12 years ago

sorry to say that, but [67366] broke something:

define the following function inline solves the problem (line 105 in debug.hpp):

        inline std::ostream &operator <<(ostream_wrapper sout_wrap, named_any t)

otherwise I get duplicate symbol definitions if I use spirit in two compilation units:

/...path.../proto/debug.hpp:105: multiple definition of `boost::proto::hidden_detail_::operator<<(boost::proto::hidden_detail_::ostream_wrapper, boost::proto::hidden_detail_::named_any)'

comment:4 by Eric Niebler, 12 years ago

oops. should be fixed in [67386]

comment:5 by Eric Niebler, 12 years ago

Resolution: fixed
Status: newclosed

(In [67387]) fix ambiguity in display_expr, fixes #4910

Note: See TracTickets for help on using tickets.