Johan RĂ¥de wrote:
So I propose that this assignment operator is added, as a VC++ 7.1 bug workaround, to the array class.
The problem with that workaround is that the array template would no longer produce aggregate types, and we would lose the ability to use brace initialization:
std::tr1::array< int, 4 > x = { 0, 1, 2, 3 };
Are you sure? An aggregate can not have user defined constructors, but I believe user defined assignment operators ar OK.
I tested with VC++ 7.1, and there my fix can be combined with aggregate initialization. (If I add a constructor though, then aggregate initialization does not work with VC++ 7.1.)
So I think my fix works.
i/ does it fail on other compilers? ii/ Is it a very specific failure with pointer-to-member, or the first hint of a more general issue that should be solved?
I have no idea. The error only seems to pop up in fairly complex situations with templates and pointer-to-members.
I've checked with VC8 and GCC-3.4 and both accept the code. However, I actually think VC7.1 is correct in rejecting it (although possibly for the wrong reasons!). Boost.Array is not intended to be either copy-constructable or assignable, so instantiating a function returning an array-by-value *should* fail to compile. Or at the very least we're in a very grey area: it all depends on whether the body of the function is instantiated when you take it's address - or just it's signature - that's the sort of thing that's entirely at the whim of the compiler :-) John.