[proto] subscript_wrapper and templated operator[]

While using proto with some classes that have a templated operator[] on VC8 and VC9, I have run into a '2 overloads have similar conversions' ambiguity error (C2666). The problem seems to be with subscript_wrapper in detail/decltype.hpp, where neither the templated operator[] from the original class nor the fallback 'any operator[](any)' function in subscript_wrapper have priority. Any thoughts on how to tweak subscript_wrapper so that the 'any operator[](any)' function looks like a worse match than the templated operator[] and thus prevents the ambiguity? I attached a small test case that reproduces the problem. Also, for reference, I am using the proto code from the release branch as of a couple days ago (~12 Jan 2009). Thanks, -Dave #include <boost/proto/proto.hpp> using namespace boost; struct Abc { template <typename T> void operator[](T const & t) { } }; template< typename Expr > void evaluate( Expr const & expr ) { proto::default_context ctx; proto::eval(expr, ctx); } int main() { Abc a; evaluate( proto::lit(a) [ 0 ] ); return 0; }

David Deakins wrote:
While using proto with some classes that have a templated operator[] on VC8 and VC9, I have run into a '2 overloads have similar conversions' ambiguity error (C2666). The problem seems to be with subscript_wrapper in detail/decltype.hpp, where neither the templated operator[] from the original class nor the fallback 'any operator[](any)' function in subscript_wrapper have priority. Any thoughts on how to tweak subscript_wrapper so that the 'any operator[](any)' function looks like a worse match than the templated operator[] and thus prevents the ambiguity? I attached a small test case that reproduces the problem. Also, for reference, I am using the proto code from the release branch as of a couple days ago (~12 Jan 2009).
I can reproduce this error with msvc but not with gcc. I think this may be a msvc bug. Sadly, I don't know of a work-around. I'll give the issue some thought. Thanks for the report. -- Eric Niebler BoostPro Computing http://www.boostpro.com

Eric Niebler wrote:
David Deakins wrote:
While using proto with some classes that have a templated operator[] on VC8 and VC9, I have run into a '2 overloads have similar conversions' ambiguity error (C2666). The problem seems to be with subscript_wrapper in detail/decltype.hpp, where neither the templated operator[] from the original class nor the fallback 'any operator[](any)' function in subscript_wrapper have priority. Any thoughts on how to tweak subscript_wrapper so that the 'any operator[](any)' function looks like a worse match than the templated operator[] and thus prevents the ambiguity? I attached a small test case that reproduces the problem. Also, for reference, I am using the proto code from the release branch as of a couple days ago (~12 Jan 2009).
I can reproduce this error with msvc but not with gcc. I think this may be a msvc bug. Sadly, I don't know of a work-around. I'll give the issue some thought.
Thanks for the report.
I've filed this bug with microsoft: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedbac... I've also committed a work-around to trunk. If the test results look good, I should have this merged to release in time for 1.38. Thanks, -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (2)
-
David Deakins
-
Eric Niebler