1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
9 #include "scoped_refptr.h"
15 typedef std::map
<std::string
, scoped_refptr
<const Foo
> > MyMap
;
18 : public std::iterator
<std::input_iterator_tag
, scoped_refptr
<const Foo
> > {
21 MyIter(const MyIter
& other
) : it_(other
.it_
) {}
22 explicit MyIter(MyMap::const_iterator it
) : it_(it
) {}
23 MyIter
& operator++() {
27 const scoped_refptr
<const Foo
> operator*() { return it_
->second
; }
28 bool operator!=(const MyIter
& other
) { return it_
!= other
.it_
; }
29 bool operator==(const MyIter
& other
) { return it_
== other
.it_
; }
32 MyMap::const_iterator it_
;
35 void TestsAScopedRefptr() {
39 MyIter
my_begin(map
.begin());
40 MyIter
my_end(map
.end());
41 for (MyIter it
= my_begin
; it
!= my_end
; ++it
) {
42 const Foo
* item
= NULL
;