Array member pointer problem: Visual Studio or me?

Jon Watte <[email protected]> Tue, 15 May 2007 09:42:02 -0700
Newsgroups gmane.games.devel.windows
Message-ID <[email protected]>
I'm having a problem where pointer to member array returns the first 
array element as a pointer to array type. There are no skanky casts 
involved in the code, so I believe this is a bug in Visual Studio 2003. 
Does anyone here agree or disagree?



template<typename Container, typename FieldType, size_t Count, FieldType 
(Container::*Field)[Count]>
class ArrayRef {
  public:
    FieldType const *Access(Container *c) { return c->*Field; }
};

class TemplateTest {
  float foo[10];
public:
  TemplateTest() {
    foo[0] = 1.0f;
    ArrayRef<TemplateTest, float, 10, &TemplateTest::foo> ar;
    float const *p = ar.Access(this);
    assert(p == foo); // p is 0x3f800000 here in msvc 2003
  }
};

TemplateTest testIt;



Cheers,

          / h+


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555