Vector with a variable range does not work : Here is my function:

when I do this:
`std::list<int> pigeonhole[100];` it works, but i need a variable here. 

when I put this, 

    std::list<int> pigeonhole(range); 

the following part fails; it says no operator "[]" matches these operands :

    pigeonhole[arr[i]-min].push_back(arr[i]); 

same thing with this part: `pigeonhole[i]`

    void pigeonholeSort(int arr[], int n)
    {
        int min = arr[0], max = arr[0];
        for (int i = 1; i < n; i++)
        {
            if (arr[i] < min)
                min = arr[i];
            if (arr[i] > max)
                max = arr[i];
        } 
    
    	int range = max - min +1;
        std::list<int> pigeonhole(range);
     
        for (int i = 0; i < n; i++)
          pigeonhole[arr[i]-min].push_back(arr[i]);
    
        int index = 0;  
        for (int i = 0; i < max; i++)
        {
           list<int>::iterator it;
           for (it = pigeonhole[i].begin(); it != pigeonhole[i].end(); ++it)
                arr[index++]  = *it;
        }
    }



