Opened 12 years ago
Closed 12 years ago
#4910 closed Patches (fixed)
ambiguity of operator<< in display_expr
Reported by: | 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)
Change History (9)
by , 12 years ago
Attachment: | display_expr-1.44.0.patch added |
---|
comment:1 by , 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 , 12 years ago
Attempted fix in [67366]. Let's see how the new display_expr tests fare on trunk.
comment:3 by , 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:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
patch against 1.44.0