# How does addition to an STL vector become an offset?

Page 1 of 1

## 2 Replies - 263 Views - Last Post: 09 November 2017 - 06:19 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=407477&amp;s=68b6ff4e21d8f5820dbe2b5a56ff0c44&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 al-khwarizmi

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 29-August 16

# How does addition to an STL vector become an offset?

Posted 09 November 2017 - 05:40 AM

http://www.cplusplus...lgorithm/equal/

In the example given here, on line 12, it says:

```std::vector<int>myvector (myints,myints+5);
```

How does that work exactly? I don't see the + operator as a member function of vectors on the same reference site.
Is This A Good Question/Topic? 0

## Replies To: How does addition to an STL vector become an offset?

### #2 sepp2k

• D.I.C Lover

Reputation: 2521
• Posts: 4,005
• Joined: 21-June 11

## Re: How does addition to an STL vector become an offset?

Posted 09 November 2017 - 05:53 AM

myints is an array, not a vector. myints are implicitly convertible to pointers and pointers do have a + operator. Specifically p + i, where p is a pointer and i is an integer, produces a pointer that points to the location i elements after where p points to.

### #3 al-khwarizmi

• New D.I.C Head

Reputation: 0
• Posts: 17
• Joined: 29-August 16

## Re: How does addition to an STL vector become an offset?

Posted 09 November 2017 - 06:19 AM

I knew that. Just misread the example. Dammit. Thanks.

This post has been edited by Skydiver: 09 November 2017 - 06:38 AM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.