Question: want to print maven dependency tree (all the dependencies including transitive dependencies) programmatically by just reading pom.xml file without connecting to remote repository.

Answer: 
When you use brace-initialization, it is forbidden for a *narrowing conversion* to be used to convert from the type of the value in the braced list to the type that the constructor actually requires. `heights[0].size()-1` has type `size_t`, and the constructor of `std::vector<int>` takes `std::initializer_list<int>`. Usually, `int` cannot represent all values of type `size_t`, which means that `size_t` to `int` is a narrowing conversion. You can fix this using an explicit cast:

```
dq.push_back({i,static_cast<int>(heights[0].size()-1)});

```

When the type being constructed is `std::pair<int, int>`, it is a different story. No conversion actually occurs when calling the constructor; instead, the following constructor is called:

```
template< class U1, class U2 >
constexpr pair( U1&& x, U2&& y );

```

See [cppreference](https://en.cppreference.com/w/cpp/utility/pair/pair).

Internally, presumably in the constructor initializer list, the constructor will convert `size_t` to `int`, but this will not be done inside braces, so it's legal.
C++ language doesn't allow narrowing implicit conversions within a braced initialiser list (unless the value compile time constant). This protects you from making certain obvious mistakes.

This is the braced initialiser list: `{i,heights[0].size()-1}`.

A narrowing conversion is a conversion into a type that cannot represent all values of the source type. The type of the expression `heights[0].size()-1` was on your system `unsigned long` which on your system can represent values that the `int` type cannot represent.

You can fix the issue by doing an explicit conversion. It is safe in this case because we know that the size is non-zero, and doesn't exceed the maximum value representable by `int`:

```
static_cast<int>(heights[0].size()-1)

```