samedi 23 octobre 2021

Is there a guaranteed address-order inside a tuple / why is it reverse?

I just discovered that with my STL-implementaton (VS2019) the address-order of the parts of a tuple is reverse. Look at this code:

#include <iostream>
#include <tuple>

using namespace std;

int main()
{
    tuple<string, string> tss( "try", "this" );
    cout << &get<1>( tss ) - &get<0>( tss ) << endl;
}

The output is:

-1

Is there a guaranted order of addresses inside a tuple or is it implementation-defined ?

Aucun commentaire:

Enregistrer un commentaire