Last change
on this file since 33 was
29,
checked in by landauf, 16 years ago
|
updated boost from 1_33_1 to 1_34_1
|
File size:
1.3 KB
|
Line | |
---|
1 | // (C) Copyright Eric Niebler 2005. |
---|
2 | // Use, modification and distribution are subject to the |
---|
3 | // Boost Software License, Version 1.0. (See accompanying file |
---|
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | /* |
---|
7 | Revision history: |
---|
8 | 25 August 2005 : Initial version. |
---|
9 | */ |
---|
10 | |
---|
11 | #include <boost/test/minimal.hpp> |
---|
12 | |
---|
13 | /////////////////////////////////////////////////////////////////////////////// |
---|
14 | // define a user-defined collection type and teach BOOST_FOREACH how to enumerate it |
---|
15 | // |
---|
16 | namespace mine |
---|
17 | { |
---|
18 | struct dummy {}; |
---|
19 | } |
---|
20 | |
---|
21 | namespace boost |
---|
22 | { |
---|
23 | char * boost_range_begin(mine::dummy&) {return 0;} |
---|
24 | char const * boost_range_begin(mine::dummy const&) {return 0;} |
---|
25 | char * boost_range_end(mine::dummy&) {return 0;} |
---|
26 | char const * boost_range_end(mine::dummy const&) {return 0;} |
---|
27 | } |
---|
28 | |
---|
29 | #include <boost/foreach.hpp> |
---|
30 | |
---|
31 | namespace boost |
---|
32 | { |
---|
33 | template<> |
---|
34 | struct range_iterator<mine::dummy> |
---|
35 | { |
---|
36 | typedef char * type; |
---|
37 | }; |
---|
38 | template<> |
---|
39 | struct range_const_iterator<mine::dummy> |
---|
40 | { |
---|
41 | typedef char const * type; |
---|
42 | }; |
---|
43 | } |
---|
44 | |
---|
45 | /////////////////////////////////////////////////////////////////////////////// |
---|
46 | // test_main |
---|
47 | // |
---|
48 | int test_main( int, char*[] ) |
---|
49 | { |
---|
50 | // loop over a user-defined type (just make sure this compiles) |
---|
51 | mine::dummy d; |
---|
52 | BOOST_FOREACH( char c, d ) |
---|
53 | { |
---|
54 | ((void)c); // no-op |
---|
55 | } |
---|
56 | |
---|
57 | return 0; |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.