Skip to content

[SUGGESTION] Confusing std::vector ctor calls in Cpp1 and Cpp2 #193

Closed
@wolfseifert

Description

@wolfseifert

In Cpp1 we have the confusing fact that

#include <vector>
using namespace ::std;
int main() {
  auto a = vector<int>{5, 1}; // vector of five and one
  auto b = vector<int>(5, 1); // vector of five ones
}

Experimenting with (pure) Cpp2 I got a similar case

main: () -> int = {
  a: std::vector<int> = (5, 1); // vector of five and one
  b := std::vector<int>(5, 1); // vector of five ones
}

This becomes clear when looking at the tanspiled code

  std::vector<int> a { 5, 1 };  // vector of five and one
  auto b { std::vector<int>(5, 1) }; // vector of five ones

For me the Cpp2 case looks even more confusing (than the Cpp1 case), because both ctor calls use parenthesis.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions