Boost logo

Boost Users :

Subject: Re: [Boost-users] [non Boost] Template troubles.
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2008-12-10 13:47:45


Robert Jones wrote:
> Have we encountered this before, and is there a known work around?

No, I have not. However, experimenting with this a bit I found that
with both your functions existing an int[] can be passed into assign.
Without the second (the T[] version) it cannot...gets the ambiguous T error.

If I try to pass an int[][] into assign I get the ambiguous error again.
  This indicates that it is something about the array type contained
within the array that is causing the problem. VS apparently doesn't
know how to derive T from T[] when T is an []. It will do it when the
second parameter is not const though. This suggests to me that it has
something to do with where the const is applied.

In int const x[5][5], the int contained within the dual array is the
constant. In the case of T const& value[] though it is T that is const,
which is an array. This is nonsense I believe (arrays are always
r-values). VS seems to have no way to handle it while the others do.

I don't know what part of the standard would apply here or who is right.
  I tried asking in comp.lang.c++ but it's not going to that group I
don't think...network here at work isn't always stable.

The workaround I'd suggest at this point is to create an assign(T &
v[][], T const& [][]). There might also be a more appropriate way to
define assign for arrays but I haven't thought of it yet. I imagine
this problem has been solved in at least some boost libraries...?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net