1 /*
2  * Qstl.h - support for quantifers when using STL under C++.
3  *
4  * Copyright (c) 1997 Phil Maker
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * Id: Qstl.h,v 1.1.1.1 1997/11/23 11:45:50 pjm Exp
29  */
30 
31 #ifndef _Qstl_h_
32 #define _Qstl_h_ 1
33 
34 #ifndef __cplusplus
35 This header file should only ever be included by a C++ program!
36 Better luck next time.
37 #error 10
38 #endif
39 
40 #include <Q.h>
41 
42 /*
43  * Warning: You might be tempted to remove the typedef from the
44  *   following code but it seems to be required by g++. Scoping
45  *   of type declarations allows us to us a fixed name.
46  */
47 
48 #define AO(name,container,predicate) \
49   ({ \
50     typedef typeof(container) _Qstl_type_; \
51     A(_Qstl_type_::iterator name = container.begin(), \
52 	name != container.end(), \
53 	++name, \
54 	predicate); \
55   })
56 
57 #define EO(name,container,predicate) \
58   ({ \
59     typedef typeof(container) _Qstl_type_; \
60     E(_Qstl_type_::iterator name = container.begin(), \
61 	name != container.end(), \
62 	++name, \
63 	predicate); \
64   })
65 
66 #define E1O(name,container,predicate) \
67   ({ \
68     typedef typeof(container) _Qstl_type_; \
69     E1(_Qstl_type_::iterator name = container.begin(), \
70 	name != container.end(), \
71 	++name, \
72 	predicate); \
73   })
74 
75 #define CO(name,container,predicate) \
76   ({ \
77     typedef typeof(container) _Qstl_type_; \
78     C(_Qstl_type_::iterator name = container.begin(), \
79 	name != container.end(), \
80 	++name, \
81 	predicate); \
82   })
83 
84 #define SO(name,container,exprn) \
85   ({ \
86     typedef typeof(container) _Qstl_type_; \
87     S(_Qstl_type_::iterator name = container.begin(), \
88 	name != container.end(), \
89 	++name, \
90 	exprn); \
91   })
92 
93 #define PO(name,container,exprn) \
94   ({ \
95     typedef typeof(container) _Qstl_type_; \
96     P(_Qstl_type_::iterator name = container.begin(), \
97 	name != container.end(), \
98 	++name, \
99 	exprn); \
100   })
101 
102 #endif
103