Q:

Count of consecutive numbers in a vector

Suppose I have the following sorted vectors as input: 
[22]
[22, 23]
[22, 46]
[22, 46, 47]
[22,23,33,44,45,46,55,56]

I want the following output which shows the count of consecutive numbers in each vector:
1 //edgecase: if there's 1 number it's consecutive)
2 //22, 23 are 2 consecutive numbers
0 //22, 46 not consecutive
2 //46, 47 are 2 consecutive numbers
7 //22,23 (2) 44,45,46 (3) 55,56(2) 7 consecutive numbers

My vector will not have duplicates. 
What I have so far is:
vector<int> numbers;
int consecCount=0;
if (numbers.size()==1)
        consecCount++;
else{
    for (size_t k=1; k<numbers.size(); k++) {
        if (numbers[k]==numbers[k-1]+1) {
            consecCount +=2;
        }
}

Of course this method doesn't work for the last array. The solution seems really wrong. 
My actual vectors are really large, so prefer any ideas that does not involve using a another vector

A:

Something like this?  
size_t conseccount(const vector<int> &v)
{
    size_t s = v.size();
    size_t ret = 0;
    bool seqstart = true;
    if(s < 2) return 0;
    for(size_t i = 1; i < s; i++)
    {
        if(v[i - 1] + 1 == v[i])
        {
            if(seqstart) ret++;
            seqstart = false;
            ret++;
        }
        else seqstart = true;
    }
    return ret;
}

