locked
Weird implementation of std::tuple ! Causing problem for DirectX developers!

    Question

  • Hi,

    Is it intended or bug in VS2012 that in std::tuple implementation the underlying data elements to be placed in raw memory in reverse order???

    Example:

    std::tuple<int,int,int> test_int;
    test_int = std::make_tuple(1,2,3);
    int first_int = std::get<0>(test_int); // =1. OK
    int second_int = std::get<1>(test_int); // =2. OK
    int third_int = std::get<2>(test_int); // =3. OK

    So far so good, but when you go at the memory location, the raw data is stored in reverse order ("00000003 00000002 00000001").That wouldn't bother me at all, but it causes huge (HUGE!) problem with DirectX. If you use tuple to create data structures (like std::vector<std::tuple<DirectX::XMFLOAT3,DirectX::XMFLOAT3>> that would represent let say vertex position and normal in this order)and then use vector's .data() to use the data for building D3D11_SUBRESOURCE_DATA's pSysMem for ID3D11BUFFER, then vertex position becomes vertex normal and vice versa.

    Why it is decided the new std::tuple implementation to be done in this weird way, rather than previous version (pretty sure wasn’t that way in VS2010, as I don't recur having this problem then).

    If it is unintended but rather overlooked implementation – can you correct it?

    Monday, December 31, 2012 9:27 AM

Answers

All replies