Skip to content

wrong result when using std::view::zip #40

Closed
@yuanzihao-1991

Description

@yuanzihao-1991

Here is my code compiled with option -std=c++23, gcc 14.2:

#include "timsort.hpp"
#include <array>
#include <iostream>
#include <tuple>
#include <vector>

int main() {
  auto x = std::vector{4, 2, 3, 1};
  auto y = std::array{'A', 'C', 'B', 'D'};
  auto xy = std::views::zip(x, y);

  gfx::timsort(xy, {},
   [](const std::tuple<int &, char &> &a) {
    return std::get<0>(a);
  });

  for (std::tuple<int &, char &> elem : xy) {
    std::cout << std::get<0>(elem) << ' ' << std::get<1>(elem) << ' ' << '\n';
  }
}

Expected result is:

1 D 
2 C 
3 B 
4 A

However, I got

4 A 
2 C 
4 A 
4 A 

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions