gccxml_gem 0.9.3-x86-darwin-10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/Rakefile +84 -0
  2. data/bin/gccxml +0 -0
  3. data/bin/gccxml_cc1plus +0 -0
  4. data/gccxml.rb +57 -0
  5. data/share/doc/gccxml-0.9/Copyright.txt +55 -0
  6. data/share/doc/gccxml-0.9/gccxml.html +168 -0
  7. data/share/doc/gccxml-0.9/gccxml.txt +293 -0
  8. data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
  9. data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
  10. data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
  11. data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
  12. data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
  13. data/share/gccxml-0.9/GCC/2.95/complex +38 -0
  14. data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
  15. data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
  16. data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
  17. data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
  18. data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
  19. data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
  20. data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
  21. data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
  22. data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
  23. data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
  24. data/share/gccxml-0.9/GCC/2.95/deque +19 -0
  25. data/share/gccxml-0.9/GCC/2.95/exception +20 -0
  26. data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
  27. data/share/gccxml-0.9/GCC/2.95/functional +64 -0
  28. data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
  29. data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
  30. data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
  31. data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
  32. data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
  33. data/share/gccxml-0.9/GCC/2.95/list +19 -0
  34. data/share/gccxml-0.9/GCC/2.95/map +20 -0
  35. data/share/gccxml-0.9/GCC/2.95/memory +21 -0
  36. data/share/gccxml-0.9/GCC/2.95/new +13 -0
  37. data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
  38. data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
  39. data/share/gccxml-0.9/GCC/2.95/queue +20 -0
  40. data/share/gccxml-0.9/GCC/2.95/set +20 -0
  41. data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
  42. data/share/gccxml-0.9/GCC/2.95/stack +19 -0
  43. data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
  44. data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
  45. data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
  46. data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
  47. data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
  48. data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
  49. data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
  50. data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
  51. data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
  52. data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
  53. data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
  54. data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
  55. data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
  56. data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
  57. data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
  58. data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
  59. data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
  60. data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
  61. data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
  62. data/share/gccxml-0.9/GCC/2.95/string +26 -0
  63. data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
  64. data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
  65. data/share/gccxml-0.9/GCC/2.95/utility +25 -0
  66. data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
  67. data/share/gccxml-0.9/GCC/2.95/vector +19 -0
  68. data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
  69. data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
  70. data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
  71. data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
  72. data/share/gccxml-0.9/GCC/3.2/bits/gthr-default.h +585 -0
  73. data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
  74. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
  75. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
  76. data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
  77. data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
  78. data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
  79. data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
  80. data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
  81. data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
  82. data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
  83. data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
  84. data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
  85. data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
  86. data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
  87. data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
  88. data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
  89. data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
  90. data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
  91. data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
  92. data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
  93. data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
  94. data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
  95. data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
  96. data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
  97. data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
  98. data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
  99. data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
  100. data/share/gccxml-0.9/GCC/3.4/bits/gthr-default.h +669 -0
  101. data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
  102. data/share/gccxml-0.9/GCC/4.0/emmintrin.h +5 -0
  103. data/share/gccxml-0.9/GCC/4.0/gccxml_apple_emmintrin.h +1037 -0
  104. data/share/gccxml-0.9/GCC/4.0/gccxml_apple_mmintrin.h +669 -0
  105. data/share/gccxml-0.9/GCC/4.0/gccxml_apple_xmmintrin.h +870 -0
  106. data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
  107. data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_emmintrin.h +977 -0
  108. data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_mmintrin.h +636 -0
  109. data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_xmmintrin.h +833 -0
  110. data/share/gccxml-0.9/GCC/4.0/mmintrin.h +5 -0
  111. data/share/gccxml-0.9/GCC/4.0/xmmintrin.h +5 -0
  112. data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +622 -0
  113. data/share/gccxml-0.9/GCC/4.1/emmintrin.h +5 -0
  114. data/share/gccxml-0.9/GCC/4.1/gccxml_apple_emmintrin.h +1509 -0
  115. data/share/gccxml-0.9/GCC/4.1/gccxml_apple_mmintrin.h +942 -0
  116. data/share/gccxml-0.9/GCC/4.1/gccxml_apple_xmmintrin.h +1192 -0
  117. data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
  118. data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_emmintrin.h +1004 -0
  119. data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_mmintrin.h +637 -0
  120. data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_xmmintrin.h +834 -0
  121. data/share/gccxml-0.9/GCC/4.1/mmintrin.h +5 -0
  122. data/share/gccxml-0.9/GCC/4.1/xmmintrin.h +5 -0
  123. data/share/gccxml-0.9/GCC/4.2/emmintrin.h +5 -0
  124. data/share/gccxml-0.9/GCC/4.2/gccxml_apple_emmintrin.h +1509 -0
  125. data/share/gccxml-0.9/GCC/4.2/gccxml_apple_mmintrin.h +942 -0
  126. data/share/gccxml-0.9/GCC/4.2/gccxml_apple_xmmintrin.h +1192 -0
  127. data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
  128. data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_emmintrin.h +1013 -0
  129. data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_mmintrin.h +663 -0
  130. data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_xmmintrin.h +860 -0
  131. data/share/gccxml-0.9/GCC/4.2/mmintrin.h +5 -0
  132. data/share/gccxml-0.9/GCC/4.2/xmmintrin.h +5 -0
  133. data/share/gccxml-0.9/GCC/4.3/emmintrin.h +1043 -0
  134. data/share/gccxml-0.9/GCC/4.3/gccxml_builtins.h +183 -0
  135. data/share/gccxml-0.9/GCC/4.3/mmintrin.h +663 -0
  136. data/share/gccxml-0.9/GCC/4.3/xmmintrin.h +867 -0
  137. data/share/gccxml-0.9/GCC/4.4/bits/c++config.h +1431 -0
  138. data/share/gccxml-0.9/GCC/4.4/emmintrin.h +1041 -0
  139. data/share/gccxml-0.9/GCC/4.4/gccxml_builtins.h +153 -0
  140. data/share/gccxml-0.9/GCC/4.4/mmintrin.h +662 -0
  141. data/share/gccxml-0.9/GCC/4.4/xmmintrin.h +864 -0
  142. data/share/gccxml-0.9/GCC/4.5/gccxml_builtins.h +154 -0
  143. data/share/gccxml-0.9/GCC/4.5/iomanip +349 -0
  144. data/share/gccxml-0.9/GCC/COPYING.RUNTIME +73 -0
  145. data/share/gccxml-0.9/GCC/COPYING3 +674 -0
  146. data/share/gccxml-0.9/IBM/8.0/adapt_headers.sh +34 -0
  147. data/share/gccxml-0.9/IBM/8.0/stdlib.h.patch +27 -0
  148. data/share/gccxml-0.9/IBM/8.0/xstring.patch +19 -0
  149. data/share/gccxml-0.9/IBM/README +8 -0
  150. data/share/gccxml-0.9/IBM/find_flags +51 -0
  151. data/share/gccxml-0.9/IBM/find_flags_common +48 -0
  152. data/share/gccxml-0.9/Intel/find_flags +56 -0
  153. data/share/gccxml-0.9/Intel/pthread.h +16 -0
  154. data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
  155. data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
  156. data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
  157. data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
  158. data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
  159. data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
  160. data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
  161. data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
  162. data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
  163. data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
  164. data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
  165. data/share/gccxml-0.9/MIPSpro/find_flags +70 -0
  166. data/share/gccxml-0.9/MIPSpro/mipspro_defs.cxx +63 -0
  167. data/share/gccxml-0.9/Sun/5.8/Cstd.patch +156 -0
  168. data/share/gccxml-0.9/Sun/5.8/adapt_headers.sh +32 -0
  169. data/share/gccxml-0.9/Sun/5.8/std-5.10.patch +22 -0
  170. data/share/gccxml-0.9/Sun/README +8 -0
  171. data/share/gccxml-0.9/Sun/find_flags +51 -0
  172. data/share/gccxml-0.9/Sun/find_flags_common +42 -0
  173. data/share/gccxml-0.9/gccxml_config +2 -0
  174. data/share/gccxml-0.9/gccxml_identify_compiler.cc +13 -0
  175. data/share/man/man1/gccxml.1 +246 -0
  176. metadata +245 -0
@@ -0,0 +1,162 @@
1
+ // Character traits template for the -*- C++ -*- string classes.
2
+ // Copyright (C) 1994 Free Software Foundation
3
+
4
+ // This file is part of the GNU ANSI C++ Library. This library is free
5
+ // software; you can redistribute it and/or modify it under the
6
+ // terms of the GNU General Public License as published by the
7
+ // Free Software Foundation; either version 2, or (at your option)
8
+ // any later version.
9
+
10
+ // This library is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU General Public License for more details.
14
+
15
+ // You should have received a copy of the GNU General Public License
16
+ // along with this library; see the file COPYING. If not, write to the Free
17
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
+
19
+ // As a special exception, if you link this library with files
20
+ // compiled with a GNU compiler to produce an executable, this does not cause
21
+ // the resulting executable to be covered by the GNU General Public License.
22
+ // This exception does not however invalidate any other reasons why
23
+ // the executable file might be covered by the GNU General Public License.
24
+
25
+ // Written by Jason Merrill based upon the specification by Takanori Adachi
26
+ // in ANSI X3J16/94-0013R2.
27
+
28
+ #ifndef __STRING_CHAR_TRAITS__
29
+ #define __STRING_CHAR_TRAITS__
30
+
31
+ #ifdef __GNUG__
32
+ // For string_char_traits <char>
33
+ #pragma interface "std/straits.h"
34
+ #endif
35
+
36
+ #include <cstddef>
37
+
38
+ extern "C++" {
39
+ template <class charT>
40
+ struct string_char_traits {
41
+ typedef charT char_type; // for users to acquire the basic character type
42
+
43
+ // constraints
44
+
45
+ static void assign (char_type& c1, const char_type& c2)
46
+ { c1 = c2; }
47
+ static bool eq (const char_type& c1, const char_type& c2)
48
+ { return (c1 == c2); }
49
+ static bool ne (const char_type& c1, const char_type& c2)
50
+ { return !(c1 == c2); }
51
+ static bool lt (const char_type& c1, const char_type& c2)
52
+ { return (c1 < c2); }
53
+ static char_type eos () { return char_type(); } // the null character
54
+ static bool is_del(char_type a) { return 0; }
55
+ // characteristic function for delimiters of charT
56
+
57
+ // speed-up functions
58
+
59
+ static int compare (const char_type* s1, const char_type* s2, size_t n)
60
+ {
61
+ size_t i;
62
+ for (i = 0; i < n; ++i)
63
+ if (ne (s1[i], s2[i]))
64
+ return lt (s1[i], s2[i]) ? -1 : 1;
65
+
66
+ return 0;
67
+ }
68
+
69
+ static size_t length (const char_type* s)
70
+ {
71
+ size_t l = 0;
72
+ while (ne (*s++, eos ()))
73
+ ++l;
74
+ return l;
75
+ }
76
+
77
+ static char_type* copy (char_type* s1, const char_type* s2, size_t n)
78
+ {
79
+ for (; n--; )
80
+ assign (s1[n], s2[n]);
81
+ return s1;
82
+ }
83
+
84
+ static char_type* move (char_type* s1, const char_type* s2, size_t n)
85
+ {
86
+ char_type a[n];
87
+ size_t i;
88
+ for (i = 0; i < n; ++i)
89
+ assign (a[i], s2[i]);
90
+ for (i = 0; i < n; ++i)
91
+ assign (s1[i], a[i]);
92
+ return s1;
93
+ }
94
+
95
+ static char_type* set (char_type* s1, const char_type& c, size_t n)
96
+ {
97
+ for (; n--; )
98
+ assign (s1[n], c);
99
+ return s1;
100
+ }
101
+ };
102
+
103
+ class istream;
104
+ class ostream;
105
+ #include <cctype>
106
+ #include <cstring>
107
+
108
+ template <>
109
+ struct string_char_traits <char> {
110
+ typedef char char_type;
111
+
112
+ static void assign (char_type& c1, const char_type& c2)
113
+ { c1 = c2; }
114
+ static bool eq (const char_type & c1, const char_type& c2)
115
+ { return (c1 == c2); }
116
+ static bool ne (const char_type& c1, const char_type& c2)
117
+ { return (c1 != c2); }
118
+ static bool lt (const char_type& c1, const char_type& c2)
119
+ { return (c1 < c2); }
120
+ static char_type eos () { return 0; }
121
+ static bool is_del(char_type a) { return isspace(a); }
122
+
123
+ static int compare (const char_type* s1, const char_type* s2, size_t n)
124
+ { return memcmp (s1, s2, n); }
125
+ static size_t length (const char_type* s)
126
+ { return strlen (s); }
127
+ static char_type* copy (char_type* s1, const char_type* s2, size_t n)
128
+ { return (char_type*) memcpy (s1, s2, n); }
129
+ static char_type* move (char_type* s1, const char_type* s2, size_t n)
130
+ { return (char_type*) memmove (s1, s2, n); }
131
+ static char_type* set (char_type* s1, const char_type& c, size_t n)
132
+ { return (char_type*) memset (s1, c, n); }
133
+ };
134
+
135
+ #if 0
136
+ #include <cwctype>
137
+ struct string_char_traits <wchar_t> {
138
+ typedef wchar_t char_type;
139
+
140
+ static void assign (char_type& c1, const char_type& c2)
141
+ { c1 = c2; }
142
+ static bool eq (const char_type & c1, const char_type& c2)
143
+ { return (c1 == c2); }
144
+ static bool ne (const char_type& c1, const char_type& c2)
145
+ { return (c1 != c2); }
146
+ static bool lt (const char_type& c1, const char_type& c2)
147
+ { return (c1 < c2); }
148
+ static char_type eos () { return 0; }
149
+ static bool is_del(char_type a) { return iswspace(a); }
150
+
151
+ static int compare (const char_type* s1, const char_type* s2, size_t n)
152
+ { return wmemcmp (s1, s2, n); }
153
+ static size_t length (const char_type* s)
154
+ { return wcslen (s); }
155
+ static char_type* copy (char_type* s1, const char_type* s2, size_t n)
156
+ { return wmemcpy (s1, s2, n); }
157
+ static char_type* set (char_type* s1, const char_type& c, size_t n)
158
+ { return wmemset (s1, c, n); }
159
+ };
160
+ #endif
161
+ } // extern "C++"
162
+ #endif
@@ -0,0 +1,1035 @@
1
+ // The template and inlines for the -*- C++ -*- internal _Meta class.
2
+
3
+ // Copyright (C) 1997-1999 Cygnus Solutions
4
+ //
5
+ // This file is part of the GNU ISO C++ Library. This library is free
6
+ // software; you can redistribute it and/or modify it under the
7
+ // terms of the GNU General Public License as published by the
8
+ // Free Software Foundation; either version 2, or (at your option)
9
+ // any later version.
10
+
11
+ // This library is distributed in the hope that it will be useful,
12
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ // GNU General Public License for more details.
15
+
16
+ // You should have received a copy of the GNU General Public License along
17
+ // with this library; see the file COPYING. If not, write to the Free
18
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19
+ // USA.
20
+
21
+ // As a special exception, you may use this file as part of a free software
22
+ // library without restriction. Specifically, if other files instantiate
23
+ // templates or use macros or inline functions from this file, or you compile
24
+ // this file and link it with other files to produce an executable, this
25
+ // file does not by itself cause the resulting executable to be covered by
26
+ // the GNU General Public License. This exception does not however
27
+ // invalidate any other reasons why the executable file might be covered by
28
+ // the GNU General Public License.
29
+
30
+ // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
31
+
32
+ #ifndef _CPP_VALARRAY_META_H
33
+ #define _CPP_VALARRAY_META_H 1
34
+
35
+ //
36
+ // Implementing a loosened valarray return value is tricky.
37
+ // First we need to meet 26.3.1/3: we should not add more than
38
+ // two levels of template nesting. Therefore we resort to template
39
+ // template to "flatten" loosened return value types.
40
+ // At some point we use partial specialization to remove one level
41
+ // template nesting due to _Expr<>
42
+ //
43
+
44
+
45
+ // This class is NOT defined. It doesn't need to.
46
+ template<typename _Tp1, typename _Tp2> class _Constant;
47
+
48
+ //
49
+ // Unary function application closure.
50
+ //
51
+ template<class _Dom> class _UnFunBase {
52
+ public:
53
+ typedef typename _Dom::value_type value_type;
54
+ typedef value_type _Vt;
55
+
56
+ _UnFunBase (const _Dom& __e, _Vt __f(_Vt))
57
+ : _M_expr(__e), _M_func(__f) {}
58
+
59
+ _Vt operator[] (size_t __i) const { return _M_func(_M_expr[__i]); }
60
+ size_t size () const { return _M_expr.size(); }
61
+
62
+ private:
63
+ const _Dom& _M_expr;
64
+ _Vt (*_M_func)(_Vt);
65
+ };
66
+
67
+ template<template<class, class> class _Meta, class _Dom> class _UnFunClos;
68
+
69
+ template<class _Dom>
70
+ struct _UnFunClos<_Expr,_Dom> : _UnFunBase<_Dom> {
71
+ typedef _UnFunBase<_Dom> _Base;
72
+ typedef typename _Base::value_type value_type;
73
+
74
+ _UnFunClos (const _Dom& __e, value_type __f(value_type))
75
+ : _Base (__e, __f) {}
76
+ };
77
+
78
+ template<typename _Tp>
79
+ struct _UnFunClos<_ValArray,_Tp> : _UnFunBase<valarray<_Tp> > {
80
+ typedef _UnFunBase<valarray<_Tp> > _Base;
81
+ typedef typename _Base::value_type value_type;
82
+
83
+ _UnFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
84
+ : _Base (__v, __f) {}
85
+ };
86
+
87
+ //
88
+ // Binary function application closure.
89
+ //
90
+ template<template<class, class> class _Meta1,
91
+ template<class, class> class Meta2,
92
+ class _Dom1, class _Dom2> class _BinFunClos;
93
+
94
+ template<class _Dom1, class _Dom2> class _BinFunBase {
95
+ public:
96
+ typedef typename _Dom1::value_type value_type;
97
+ typedef value_type _Vt;
98
+
99
+ _BinFunBase (const _Dom1& __e1, const _Dom2& __e2,
100
+ _Vt __f (_Vt, _Vt))
101
+ : _M_expr1 (__e1), _M_expr2 (__e2), _M_func (__f) {}
102
+
103
+ value_type operator[] (size_t __i) const
104
+ { return _M_func (_M_expr1[__i], _M_expr2[__i]); }
105
+ size_t size () const { return _M_expr1.size (); }
106
+
107
+ private:
108
+ const _Dom1& _M_expr1;
109
+ const _Dom2& _M_expr2;
110
+ _Vt (*_M_func)(_Vt, _Vt);
111
+ };
112
+
113
+ template<class _Dom> class _BinFunBase1 {
114
+ public:
115
+ typedef typename _Dom::value_type value_type ;
116
+ typedef value_type _Vt;
117
+
118
+ _BinFunBase1 (const _Vt& __c, const _Dom& __e, _Vt __f(_Vt, _Vt))
119
+ : _M_expr1 (__c), _M_expr2 (__e), _M_func (__f) {}
120
+
121
+ value_type operator[] (size_t __i) const
122
+ { return _M_func (_M_expr1, _M_expr2[__i]); }
123
+ size_t size () const { return _M_expr2.size (); }
124
+
125
+ private:
126
+ const _Vt& _M_expr1;
127
+ const _Dom& _M_expr2;
128
+ _Vt (*_M_func)(_Vt, _Vt);
129
+ };
130
+
131
+ template<class _Dom> class _BinFunBase2 {
132
+ public:
133
+ typedef typename _Dom::value_type value_type;
134
+ typedef value_type _Vt;
135
+
136
+ _BinFunBase2 (const _Dom& __e, const _Vt& __c, _Vt __f(_Vt, _Vt))
137
+ : _M_expr1 (__e), _M_expr2 (__c), _M_func (__f) {}
138
+
139
+ value_type operator[] (size_t __i) const
140
+ { return _M_func (_M_expr1[__i], _M_expr2); }
141
+ size_t size () const { return _M_expr1.size (); }
142
+
143
+ private:
144
+ const _Dom& _M_expr1;
145
+ const _Vt& _M_expr2;
146
+ _Vt (*_M_func)(_Vt, _Vt);
147
+ };
148
+
149
+ template<class _Dom1, class _Dom2>
150
+ struct _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> : _BinFunBase<_Dom1,_Dom2> {
151
+ typedef _BinFunBase<_Dom1,_Dom2> _Base;
152
+ typedef typename _Base::value_type value_type;
153
+ typedef value_type _Tp;
154
+
155
+ _BinFunClos (const _Dom1& __e1, const _Dom2& __e2,
156
+ _Tp __f(_Tp, _Tp))
157
+ : _Base (__e1, __e2, __f) {}
158
+ };
159
+
160
+ template<typename _Tp>
161
+ struct _BinFunClos<_ValArray,_ValArray,_Tp,_Tp>
162
+ : _BinFunBase<valarray<_Tp>, valarray<_Tp> > {
163
+ typedef _BinFunBase<valarray<_Tp>, valarray<_Tp> > _Base;
164
+ typedef _Tp value_type;
165
+
166
+ _BinFunClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w,
167
+ _Tp __f(_Tp, _Tp))
168
+ : _Base (__v, __w, __f) {}
169
+ };
170
+
171
+ template<class _Dom>
172
+ struct _BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>
173
+ : _BinFunBase<_Dom,valarray<typename _Dom::value_type> > {
174
+ typedef typename _Dom::value_type _Tp;
175
+ typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
176
+ typedef _Tp value_type;
177
+
178
+ _BinFunClos (const _Dom& __e, const valarray<_Tp>& __v,
179
+ _Tp __f(_Tp, _Tp))
180
+ : _Base (__e, __v, __f) {}
181
+ };
182
+
183
+ template<class _Dom>
184
+ struct _BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>
185
+ : _BinFunBase<valarray<typename _Dom::value_type>,_Dom> {
186
+ typedef typename _Dom::value_type _Tp;
187
+ typedef _BinFunBase<_Dom,valarray<_Tp> > _Base;
188
+ typedef _Tp value_type;
189
+
190
+ _BinFunClos (const valarray<_Tp>& __v, const _Dom& __e,
191
+ _Tp __f(_Tp, _Tp))
192
+ : _Base (__v, __e, __f) {}
193
+ };
194
+
195
+ template<class _Dom>
196
+ struct _BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>
197
+ : _BinFunBase2<_Dom> {
198
+ typedef typename _Dom::value_type _Tp;
199
+ typedef _Tp value_type;
200
+ typedef _BinFunBase2<_Dom> _Base;
201
+
202
+ _BinFunClos (const _Dom& __e, const _Tp& __t, _Tp __f (_Tp, _Tp))
203
+ : _Base (__e, __t, __f) {}
204
+ };
205
+
206
+ template<class _Dom>
207
+ struct _BinFunClos<_Constant,_Expr,_Dom,typename _Dom::value_type>
208
+ : _BinFunBase1<_Dom> {
209
+ typedef typename _Dom::value_type _Tp;
210
+ typedef _Tp value_type;
211
+ typedef _BinFunBase1<_Dom> _Base;
212
+
213
+ _BinFunClos (const _Tp& __t, const _Dom& __e, _Tp __f (_Tp, _Tp))
214
+ : _Base (__t, __e, __f) {}
215
+ };
216
+
217
+ template<typename _Tp>
218
+ struct _BinFunClos<_ValArray,_Constant,_Tp,_Tp>
219
+ : _BinFunBase2<valarray<_Tp> > {
220
+ typedef _BinFunBase2<valarray<_Tp> > _Base;
221
+ typedef _Tp value_type;
222
+
223
+ _BinFunClos (const valarray<_Tp>& __v, const _Tp& __t,
224
+ _Tp __f(_Tp, _Tp))
225
+ : _Base (__v, __t, __f) {}
226
+ };
227
+
228
+ template<typename _Tp>
229
+ struct _BinFunClos<_Constant,_ValArray,_Tp,_Tp>
230
+ : _BinFunBase1<valarray<_Tp> > {
231
+ typedef _BinFunBase1<valarray<_Tp> > _Base;
232
+ typedef _Tp value_type;
233
+
234
+ _BinFunClos (const _Tp& __t, const valarray<_Tp>& __v,
235
+ _Tp __f (_Tp, _Tp))
236
+ : _Base (__t, __v, __f) {}
237
+ };
238
+
239
+ //
240
+ // Apply function taking a value/const reference closure
241
+ //
242
+
243
+ template<typename _Dom, typename _Arg> class _FunBase {
244
+ public:
245
+ typedef typename _Dom::value_type value_type;
246
+
247
+ _FunBase (const _Dom& __e, value_type __f(_Arg))
248
+ : _M_expr (__e), _M_func (__f) {}
249
+
250
+ value_type operator[] (size_t __i) const
251
+ { return _M_func (_M_expr[__i]); }
252
+ size_t size() const { return _M_expr.size ();}
253
+
254
+ private:
255
+ const _Dom& _M_expr;
256
+ value_type (*_M_func)(_Arg);
257
+ };
258
+
259
+ template<class _Dom>
260
+ struct _ValFunClos<_Expr,_Dom>
261
+ : _FunBase<_Dom, typename _Dom::value_type> {
262
+ typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
263
+ typedef typename _Base::value_type value_type;
264
+ typedef value_type _Tp;
265
+
266
+ _ValFunClos (const _Dom& __e, _Tp __f (_Tp)) : _Base (__e, __f) {}
267
+ };
268
+
269
+ template<typename _Tp>
270
+ struct _ValFunClos<_ValArray,_Tp>
271
+ : _FunBase<valarray<_Tp>, _Tp> {
272
+ typedef _FunBase<valarray<_Tp>, _Tp> _Base;
273
+ typedef _Tp value_type;
274
+
275
+ _ValFunClos (const valarray<_Tp>& __v, _Tp __f(_Tp))
276
+ : _Base (__v, __f) {}
277
+ };
278
+
279
+ template<class _Dom>
280
+ struct _RefFunClos<_Expr,_Dom> :
281
+ _FunBase<_Dom, const typename _Dom::value_type&> {
282
+ typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
283
+ typedef typename _Base::value_type value_type;
284
+ typedef value_type _Tp;
285
+
286
+ _RefFunClos (const _Dom& __e, _Tp __f (const _Tp&))
287
+ : _Base (__e, __f) {}
288
+ };
289
+
290
+ template<typename _Tp>
291
+ struct _RefFunClos<_ValArray,_Tp>
292
+ : _FunBase<valarray<_Tp>, const _Tp&> {
293
+ typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
294
+ typedef _Tp value_type;
295
+
296
+ _RefFunClos (const valarray<_Tp>& __v, _Tp __f(const _Tp&))
297
+ : _Base (__v, __f) {}
298
+ };
299
+
300
+ //
301
+ // Unary expression closure.
302
+ //
303
+
304
+ template<template<class> class _Oper, typename _Arg>
305
+ class _UnBase {
306
+ public:
307
+ typedef _Oper<typename _Arg::value_type> _Op;
308
+ typedef typename _Op::result_type value_type;
309
+
310
+ _UnBase (const _Arg& __e) : _M_expr(__e) {}
311
+ value_type operator[] (size_t) const;
312
+ size_t size () const { return _M_expr.size (); }
313
+
314
+ private:
315
+ const _Arg& _M_expr;
316
+ };
317
+
318
+ template<template<class> class _Oper, typename _Arg>
319
+ inline typename _UnBase<_Oper, _Arg>::value_type
320
+ _UnBase<_Oper, _Arg>::operator[] (size_t __i) const
321
+ { return _Op() (_M_expr[__i]); }
322
+
323
+ template<template<class> class _Oper, class _Dom>
324
+ struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> {
325
+ typedef _Dom _Arg;
326
+ typedef _UnBase<_Oper, _Dom> _Base;
327
+ typedef typename _Base::value_type value_type;
328
+
329
+ _UnClos (const _Arg& __e) : _Base(__e) {}
330
+ };
331
+
332
+ template<template<class> class _Oper, typename _Tp>
333
+ struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
334
+ typedef valarray<_Tp> _Arg;
335
+ typedef _UnBase<_Oper, valarray<_Tp> > _Base;
336
+ typedef typename _Base::value_type value_type;
337
+
338
+ _UnClos (const _Arg& __e) : _Base(__e) {}
339
+ };
340
+
341
+
342
+ //
343
+ // Binary expression closure.
344
+ //
345
+
346
+ template<template<class> class _Oper, typename _FirstArg, typename _SecondArg>
347
+ class _BinBase {
348
+ public:
349
+ typedef _Oper<typename _FirstArg::value_type> _Op;
350
+ typedef typename _Op::result_type value_type;
351
+
352
+ _BinBase (const _FirstArg& __e1, const _SecondArg& __e2)
353
+ : _M_expr1 (__e1), _M_expr2 (__e2) {}
354
+ value_type operator[] (size_t) const;
355
+ size_t size () const { return _M_expr1.size (); }
356
+
357
+ private:
358
+ const _FirstArg& _M_expr1;
359
+ const _SecondArg& _M_expr2;
360
+ };
361
+
362
+ template<template<class> class _Oper, typename _FirstArg, typename _SecondArg>
363
+ inline typename _BinBase<_Oper,_FirstArg,_SecondArg>::value_type
364
+ _BinBase<_Oper,_FirstArg,_SecondArg>::operator[] (size_t __i) const
365
+ { return _Op() (_M_expr1[__i], _M_expr2[__i]); }
366
+
367
+
368
+ template<template<class> class _Oper, class _Clos>
369
+ class _BinBase2 {
370
+ public:
371
+ typedef typename _Clos::value_type _Vt;
372
+ typedef _Oper<_Vt> _Op;
373
+ typedef typename _Op::result_type value_type;
374
+
375
+ _BinBase2 (const _Clos& __e, const _Vt& __t)
376
+ : _M_expr1 (__e), _M_expr2 (__t) {}
377
+ value_type operator[] (size_t) const;
378
+ size_t size () const { return _M_expr1.size (); }
379
+
380
+ private:
381
+ const _Clos& _M_expr1;
382
+ const _Vt& _M_expr2;
383
+ };
384
+
385
+ template<template<class> class _Oper, class _Clos>
386
+ inline typename _BinBase2<_Oper,_Clos>::value_type
387
+ _BinBase2<_Oper,_Clos>::operator[] (size_t __i) const
388
+ { return _Op() (_M_expr1[__i], _M_expr2); }
389
+
390
+
391
+ template<template<class> class _Oper, class _Clos>
392
+ class _BinBase1 {
393
+ public:
394
+ typedef typename _Clos::value_type _Vt;
395
+ typedef _Oper<_Vt> _Op;
396
+ typedef typename _Op::result_type value_type;
397
+
398
+ _BinBase1 (const _Vt& __t, const _Clos& __e)
399
+ : _M_expr1 (__t), _M_expr2 (__e) {}
400
+ value_type operator[] (size_t) const;
401
+ size_t size () const { return _M_expr2.size (); }
402
+
403
+ private:
404
+ const _Vt& _M_expr1;
405
+ const _Clos& _M_expr2;
406
+ };
407
+
408
+ template<template<class> class _Oper, class _Clos>
409
+ inline typename
410
+ _BinBase1<_Oper,_Clos>::value_type
411
+ _BinBase1<_Oper,_Clos>:: operator[] (size_t __i) const
412
+ { return _Op() (_M_expr1, _M_expr2[__i]); }
413
+
414
+
415
+ template<template<class> class _Oper, class _Dom1, class _Dom2>
416
+ struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
417
+ : _BinBase<_Oper,_Dom1,_Dom2> {
418
+ typedef _BinBase<_Oper,_Dom1,_Dom2> _Base;
419
+ typedef typename _Base::value_type value_type;
420
+
421
+ _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
422
+ };
423
+
424
+ template<template<class> class _Oper, typename _Tp>
425
+ struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp>
426
+ : _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > {
427
+ typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base;
428
+ typedef _Tp value_type;
429
+
430
+ _BinClos (const valarray<_Tp>& __v, const valarray<_Tp>& __w)
431
+ : _Base (__v, __w) {}
432
+ };
433
+
434
+ template<template<class> class _Oper, class _Dom>
435
+ struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type>
436
+ : _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> > {
437
+ typedef typename _Dom::value_type _Tp;
438
+ typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
439
+ typedef typename _Base::value_type value_type;
440
+
441
+ _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2)
442
+ : _Base (__e1, __e2) {}
443
+ };
444
+
445
+ template<template<class> class _Oper, class _Dom>
446
+ struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom>
447
+ : _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom> {
448
+ typedef typename _Dom::value_type _Tp;
449
+ typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base;
450
+ typedef typename _Base::value_type value_type;
451
+
452
+ _BinClos (const valarray<_Tp>& __e1, const _Dom& __e2)
453
+ : _Base (__e1, __e2) {}
454
+ };
455
+
456
+ template<template<class> class _Oper, class _Dom>
457
+ struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type>
458
+ : _BinBase2<_Oper,_Dom> {
459
+ typedef typename _Dom::value_type _Tp;
460
+ typedef _BinBase2<_Oper,_Dom> _Base;
461
+ typedef typename _Base::value_type value_type;
462
+
463
+ _BinClos (const _Dom& __e1, const _Tp& __e2) : _Base (__e1, __e2) {}
464
+ };
465
+
466
+ template<template<class> class _Oper, class _Dom>
467
+ struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom>
468
+ : _BinBase1<_Oper,_Dom> {
469
+ typedef typename _Dom::value_type _Tp;
470
+ typedef _BinBase1<_Oper,_Dom> _Base;
471
+ typedef typename _Base::value_type value_type;
472
+
473
+ _BinClos (const _Tp& __e1, const _Dom& __e2) : _Base (__e1, __e2) {}
474
+ };
475
+
476
+ template<template<class> class _Oper, typename _Tp>
477
+ struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp>
478
+ : _BinBase2<_Oper,valarray<_Tp> > {
479
+ typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
480
+ typedef typename _Base::value_type value_type;
481
+
482
+ _BinClos (const valarray<_Tp>& __v, const _Tp& __t)
483
+ : _Base (__v, __t) {}
484
+ };
485
+
486
+ template<template<class> class _Oper, typename _Tp>
487
+ struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp>
488
+ : _BinBase1<_Oper,valarray<_Tp> > {
489
+ typedef _BinBase1<_Oper,valarray<_Tp> > _Base;
490
+ typedef typename _Base::value_type value_type;
491
+
492
+ _BinClos (const _Tp& __t, const valarray<_Tp>& __v)
493
+ : _Base (__t, __v) {}
494
+ };
495
+
496
+
497
+ //
498
+ // slice_array closure.
499
+ //
500
+ template<typename _Dom> class _SBase {
501
+ public:
502
+ typedef typename _Dom::value_type value_type;
503
+
504
+ _SBase (const _Dom& __e, const slice& __s)
505
+ : _M_expr (__e), _M_slice (__s) {}
506
+ value_type operator[] (size_t __i) const;
507
+ size_t size() const;
508
+
509
+ private:
510
+ const _Dom& _M_expr;
511
+ const slice& _M_slice;
512
+ };
513
+
514
+ template<typename _Tp> class _SBase<_Array<_Tp> > {
515
+ public:
516
+ typedef _Tp value_type;
517
+
518
+ _SBase (_Array<_Tp> __a, const slice& __s);
519
+ value_type operator[] (size_t __i) const
520
+ { return _M_array._M_data[__i * _M_stride]; }
521
+ size_t size() const { return _M_size; }
522
+
523
+ private:
524
+ const _Array<_Tp> _M_array;
525
+ const size_t _M_size;
526
+ const size_t _M_stride;
527
+ };
528
+
529
+ template<class _Dom> struct _SClos<_Expr,_Dom> : _SBase<_Dom> {
530
+ typedef _SBase<_Dom> _Base;
531
+ typedef typename _Base::value_type value_type;
532
+
533
+ _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {}
534
+ };
535
+
536
+ template<typename _Tp>
537
+ struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > {
538
+ typedef _SBase<_Array<_Tp> > _Base;
539
+ typedef _Tp value_type;
540
+
541
+ _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {}
542
+ };
543
+
544
+ //
545
+ // gslice_array closure.
546
+ //
547
+ template<class _Dom> class _GBase {
548
+ public:
549
+ typedef typename _Dom::value_type value_type;
550
+
551
+ _GBase (const _Dom& __e, const valarray<size_t>& __i)
552
+ : _M_expr (__e), _M_index(__i) {}
553
+ value_type operator[] (size_t __i) const;
554
+ size_t size () const;
555
+
556
+ private:
557
+ const _Dom& _M_expr;
558
+ const valarray<size_t>& _M_index;
559
+ };
560
+
561
+ template<typename _Tp> class _GBase<_Array<_Tp> > {
562
+ public:
563
+ typedef _Tp value_type;
564
+
565
+ _GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
566
+ : _M_array (__a), _M_index(__i) {}
567
+ value_type operator[] (size_t __i) const;
568
+ size_t size () const;
569
+
570
+ private:
571
+ const _Array<_Tp> _M_array;
572
+ const valarray<size_t>& _M_index;
573
+ };
574
+
575
+ template<class _Dom> struct _GClos<_Expr,_Dom> : _GBase<_Dom> {
576
+ typedef _GBase<_Dom> _Base;
577
+ typedef typename _Base::value_type value_type;
578
+
579
+ _GClos (const _Dom& __e, const valarray<size_t>& __i)
580
+ : _Base (__e, __i) {}
581
+ };
582
+
583
+ template<typename _Tp>
584
+ struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > {
585
+ typedef _GBase<_Array<_Tp> > _Base;
586
+ typedef typename _Base::value_type value_type;
587
+
588
+ _GClos (_Array<_Tp> __a, const valarray<size_t>& __i)
589
+ : _Base (__a, __i) {}
590
+ };
591
+
592
+ //
593
+ // indirect_array closure
594
+ //
595
+
596
+ template<class _Dom> class _IBase {
597
+ public:
598
+ typedef typename _Dom::value_type value_type;
599
+
600
+ _IBase (const _Dom& __e, const valarray<size_t>& __i)
601
+ : _M_expr (__e), _M_index (__i) {}
602
+ value_type operator[] (size_t __i) const;
603
+ size_t size() const;
604
+
605
+ private:
606
+ const _Dom& _M_expr;
607
+ const valarray<size_t>& _M_index;
608
+ };
609
+
610
+ template<class _Dom> struct _IClos<_Expr,_Dom> : _IBase<_Dom> {
611
+ typedef _IBase<_Dom> _Base;
612
+ typedef typename _Base::value_type value_type;
613
+
614
+ _IClos (const _Dom& __e, const valarray<size_t>& __i)
615
+ : _Base (__e, __i) {}
616
+ };
617
+
618
+ template<typename _Tp>
619
+ struct _IClos<_ValArray,_Tp> : _IBase<valarray<_Tp> > {
620
+ typedef _IBase<valarray<_Tp> > _Base;
621
+ typedef _Tp value_type;
622
+
623
+ _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)
624
+ : _Base (__a, __i) {}
625
+ };
626
+
627
+ //
628
+ // class _Expr
629
+ //
630
+ template<class _Clos, typename _Tp> class _Expr {
631
+ public:
632
+ typedef _Tp value_type;
633
+
634
+ _Expr (const _Clos&);
635
+
636
+ const _Clos& operator() () const;
637
+
638
+ value_type operator[] (size_t) const;
639
+ valarray<value_type> operator[] (slice) const;
640
+ valarray<value_type> operator[] (const gslice&) const;
641
+ valarray<value_type> operator[] (const valarray<bool>&) const;
642
+ valarray<value_type> operator[] (const valarray<size_t>&) const;
643
+
644
+ _Expr<_UnClos<_Unary_plus,::_Expr,_Clos>, value_type>
645
+ operator+ () const;
646
+
647
+ _Expr<_UnClos<negate,::_Expr,_Clos>, value_type>
648
+ operator- () const;
649
+
650
+ _Expr<_UnClos<_Bitwise_not,::_Expr,_Clos>, value_type>
651
+ operator~ () const;
652
+
653
+ _Expr<_UnClos<logical_not,::_Expr,_Clos>, bool>
654
+ operator! () const;
655
+
656
+ size_t size () const;
657
+ value_type sum () const;
658
+
659
+ valarray<value_type> shift (int) const;
660
+ valarray<value_type> cshift (int) const;
661
+ // _Meta<_ApplyFunctionWithValue<_Expr>, value_type>
662
+ // apply (value_type _M_func (value_type)) const;
663
+ // _Meta<_ApplyFunctionWithConstRef<_Expr>, value_type>
664
+ // apply (value_type _M_func (const value_type&)) const;
665
+
666
+ private:
667
+ const _Clos _M_closure;
668
+ };
669
+
670
+ template<class _Clos, typename _Tp>
671
+ inline
672
+ _Expr<_Clos,_Tp>::_Expr (const _Clos& __c) : _M_closure(__c) {}
673
+
674
+ template<class _Clos, typename _Tp>
675
+ inline const _Clos&
676
+ _Expr<_Clos,_Tp>::operator() () const
677
+ { return _M_closure; }
678
+
679
+ template<class _Clos, typename _Tp>
680
+ inline _Tp
681
+ _Expr<_Clos,_Tp>::operator[] (size_t __i) const
682
+ { return _M_closure[__i]; }
683
+
684
+ template<class _Clos, typename _Tp>
685
+ inline valarray<_Tp>
686
+ _Expr<_Clos,_Tp>::operator[] (const gslice& __gs) const
687
+ { return _M_closure[__gs]; }
688
+
689
+ template<class _Clos, typename _Tp>
690
+ inline valarray<_Tp>
691
+ _Expr<_Clos,_Tp>::operator[] (const valarray<bool>& __m) const
692
+ { return _M_closure[__m]; }
693
+
694
+ template<class _Clos, typename _Tp>
695
+ inline valarray<_Tp>
696
+ _Expr<_Clos,_Tp>::operator[] (const valarray<size_t>& __i) const
697
+ { return _M_closure[__i]; }
698
+
699
+ template<class _Clos, typename _Tp>
700
+ inline size_t
701
+ _Expr<_Clos,_Tp>::size () const { return _M_closure.size (); }
702
+
703
+ // XXX: replace this with a more robust summation algorithm.
704
+ template<class _Clos, typename _Tp>
705
+ inline _Tp
706
+ _Expr<_Clos,_Tp>::sum () const
707
+ {
708
+ _Tp __s(_Tp());
709
+ size_t __n (_M_closure.size ());
710
+ for (size_t __i=0; __i<__n; ++__i) __s += _M_closure[__i];
711
+ return __s;
712
+ }
713
+
714
+ template<class _Dom, typename _Tp>
715
+ inline _Tp
716
+ min (const _Expr<_Dom,_Tp>& __e)
717
+ {
718
+ size_t __s (__e.size ());
719
+ _Tp __m (__e[0]);
720
+ for (size_t __i=1; __i<__s; ++__i)
721
+ if (__m > __e[__i]) __m = __e[__i];
722
+ return __m;
723
+ }
724
+
725
+ template<class _Dom, typename _Tp>
726
+ inline _Tp
727
+ max (const _Expr<_Dom,_Tp>& __e)
728
+ {
729
+ size_t __s (__e.size());
730
+ _Tp __m (__e[0]);
731
+ for (size_t __i=1; __i<__s; ++__i)
732
+ if (__m < __e[__i]) __m = __e[__i];
733
+ return __m;
734
+ }
735
+
736
+ template<class _Dom, typename _Tp>
737
+ inline _Expr<_UnClos<logical_not,_Expr,_Dom>, bool>
738
+ _Expr<_Dom,_Tp>::operator! () const
739
+ {
740
+ typedef _UnClos<logical_not,::_Expr,_Dom> _Closure;
741
+ return _Expr<_Closure,_Tp> (_Closure(this->_M_closure));
742
+ }
743
+
744
+ #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
745
+ template<class _Dom, typename _Tp> \
746
+ inline _Expr<_UnClos<_Name,_Expr,_Dom>,_Tp> \
747
+ _Expr<_Dom,_Tp>::operator _Op () const \
748
+ { \
749
+ typedef _UnClos<_Name,::_Expr,_Dom> _Closure; \
750
+ return _Expr<_Closure,_Tp> (_Closure (this->_M_closure)); \
751
+ }
752
+
753
+ _DEFINE_EXPR_UNARY_OPERATOR(+, _Unary_plus)
754
+ _DEFINE_EXPR_UNARY_OPERATOR(-, negate)
755
+ _DEFINE_EXPR_UNARY_OPERATOR(~, _Bitwise_not)
756
+
757
+ #undef _DEFINE_EXPR_UNARY_OPERATOR
758
+
759
+
760
+ #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
761
+ template<class _Dom1, class _Dom2> \
762
+ inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \
763
+ typename _Name<typename _Dom1::value_type>::result_type> \
764
+ operator _Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
765
+ const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
766
+ { \
767
+ typedef typename _Dom1::value_type _Arg; \
768
+ typedef typename _Name<_Arg>::result_type _Value; \
769
+ typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
770
+ return _Expr<_Closure,_Value> (_Closure (__v (), __w ())); \
771
+ } \
772
+ \
773
+ template<class _Dom> \
774
+ inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
775
+ typename _Name<typename _Dom::value_type>::result_type> \
776
+ operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
777
+ const typename _Dom::value_type& __t) \
778
+ { \
779
+ typedef typename _Dom::value_type _Arg; \
780
+ typedef typename _Name<_Arg>::result_type _Value; \
781
+ typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
782
+ return _Expr<_Closure,_Value> (_Closure (__v (), __t)); \
783
+ } \
784
+ \
785
+ template<class _Dom> \
786
+ inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
787
+ typename _Name<typename _Dom::value_type>::result_type> \
788
+ operator _Op (const typename _Dom::value_type& __t, \
789
+ const _Expr<_Dom,typename _Dom::value_type>& __v) \
790
+ { \
791
+ typedef typename _Dom::value_type _Arg; \
792
+ typedef typename _Name<_Arg>::result_type _Value; \
793
+ typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
794
+ return _Expr<_Closure,_Value> (_Closure (__t, __v ())); \
795
+ } \
796
+ \
797
+ template<class _Dom> \
798
+ inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
799
+ typename _Name<typename _Dom::value_type>::result_type> \
800
+ operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
801
+ const valarray<typename _Dom::value_type>& __v) \
802
+ { \
803
+ typedef typename _Dom::value_type _Arg; \
804
+ typedef typename _Name<_Arg>::result_type _Value; \
805
+ typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \
806
+ return _Expr<_Closure,_Value> (_Closure (__e (), __v)); \
807
+ } \
808
+ \
809
+ template<class _Dom> \
810
+ inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
811
+ typename _Name<typename _Dom::value_type>::result_type> \
812
+ operator _Op (const valarray<typename _Dom::value_type>& __v, \
813
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
814
+ { \
815
+ typedef typename _Dom::value_type _Tp; \
816
+ typedef typename _Name<_Tp>::result_type _Value; \
817
+ typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
818
+ return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \
819
+ }
820
+
821
+ _DEFINE_EXPR_BINARY_OPERATOR(+, plus)
822
+ _DEFINE_EXPR_BINARY_OPERATOR(-, minus)
823
+ _DEFINE_EXPR_BINARY_OPERATOR(*, multiplies)
824
+ _DEFINE_EXPR_BINARY_OPERATOR(/, divides)
825
+ _DEFINE_EXPR_BINARY_OPERATOR(%, modulus)
826
+ _DEFINE_EXPR_BINARY_OPERATOR(^, _Bitwise_xor)
827
+ _DEFINE_EXPR_BINARY_OPERATOR(&, _Bitwise_and)
828
+ _DEFINE_EXPR_BINARY_OPERATOR(|, _Bitwise_or)
829
+ _DEFINE_EXPR_BINARY_OPERATOR(<<, _Shift_left)
830
+ _DEFINE_EXPR_BINARY_OPERATOR(>>, _Shift_right)
831
+
832
+ #undef _DEFINE_EXPR_BINARY_OPERATOR
833
+
834
+ #define _DEFINE_EXPR_RELATIONAL_OPERATOR(_Op, _Name) \
835
+ template<class _Dom1, class _Dom2> \
836
+ inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, bool> \
837
+ operator _Op (const _Expr<_Dom1,typename _Dom1::value_type>& __v, \
838
+ const _Expr<_Dom2,typename _Dom2::value_type>& __w) \
839
+ { \
840
+ typedef typename _Dom1::value_type _Arg; \
841
+ typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \
842
+ return _Expr<_Closure,bool> (_Closure (__v (), __w ())); \
843
+ } \
844
+ \
845
+ template<class _Dom> \
846
+ inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>, \
847
+ bool> \
848
+ operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __v, \
849
+ const typename _Dom::value_type& __t) \
850
+ { \
851
+ typedef typename _Dom::value_type _Arg; \
852
+ typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \
853
+ return _Expr<_Closure,bool> (_Closure (__v (), __t)); \
854
+ } \
855
+ \
856
+ template<class _Dom> \
857
+ inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>, \
858
+ bool> \
859
+ operator _Op (const typename _Dom::value_type& __t, \
860
+ const _Expr<_Dom,typename _Dom::value_type>& __v) \
861
+ { \
862
+ typedef typename _Dom::value_type _Arg; \
863
+ typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \
864
+ return _Expr<_Closure,bool> (_Closure (__t, __v ())); \
865
+ } \
866
+ \
867
+ template<class _Dom> \
868
+ inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
869
+ bool> \
870
+ operator _Op (const _Expr<_Dom,typename _Dom::value_type>& __e, \
871
+ const valarray<typename _Dom::value_type>& __v) \
872
+ { \
873
+ typedef typename _Dom::value_type _Tp; \
874
+ typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Tp> _Closure; \
875
+ return _Expr<_Closure,bool> (_Closure (__e (), __v)); \
876
+ } \
877
+ \
878
+ template<class _Dom> \
879
+ inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
880
+ bool> \
881
+ operator _Op (const valarray<typename _Dom::value_type>& __v, \
882
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
883
+ { \
884
+ typedef typename _Dom::value_type _Tp; \
885
+ typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \
886
+ return _Expr<_Closure,bool> (_Closure (__v, __e ())); \
887
+ }
888
+
889
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(&&, logical_and)
890
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(||, logical_or)
891
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(==, equal_to)
892
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(!=, not_equal_to)
893
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(<, less)
894
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(>, greater)
895
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(<=, less_equal)
896
+ _DEFINE_EXPR_RELATIONAL_OPERATOR(>=, greater_equal)
897
+
898
+ #undef _DEFINE_EXPR_RELATIONAL_OPERATOR
899
+
900
+
901
+
902
+ #define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
903
+ template<class _Dom> \
904
+ inline _Expr<_UnFunClos<_Expr,_Dom>,typename _Dom::value_type> \
905
+ _Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \
906
+ { \
907
+ typedef typename _Dom::value_type _Tp; \
908
+ typedef _UnFunClos<_Expr,_Dom> _Closure; \
909
+ return _Expr<_Closure,_Tp>(_Closure(__e(), (_Tp(*)(_Tp))(&_Name))); \
910
+ } \
911
+ \
912
+ template<typename _Tp> \
913
+ inline _Expr<_UnFunClos<_ValArray,_Tp>,_Tp> \
914
+ _Name(const valarray<_Tp>& __v) \
915
+ { \
916
+ typedef _UnFunClos<_ValArray,_Tp> _Closure; \
917
+ return _Expr<_Closure,_Tp> (_Closure (__v, (_Tp(*)(_Tp))(&_Name))); \
918
+ }
919
+
920
+
921
+ _DEFINE_EXPR_UNARY_FUNCTION(abs)
922
+ _DEFINE_EXPR_UNARY_FUNCTION(cos)
923
+ _DEFINE_EXPR_UNARY_FUNCTION(acos)
924
+ _DEFINE_EXPR_UNARY_FUNCTION(cosh)
925
+ _DEFINE_EXPR_UNARY_FUNCTION(sin)
926
+ _DEFINE_EXPR_UNARY_FUNCTION(asin)
927
+ _DEFINE_EXPR_UNARY_FUNCTION(sinh)
928
+ _DEFINE_EXPR_UNARY_FUNCTION(tan)
929
+ _DEFINE_EXPR_UNARY_FUNCTION(tanh)
930
+ _DEFINE_EXPR_UNARY_FUNCTION(atan)
931
+ _DEFINE_EXPR_UNARY_FUNCTION(exp)
932
+ _DEFINE_EXPR_UNARY_FUNCTION(log)
933
+ _DEFINE_EXPR_UNARY_FUNCTION(log10)
934
+ _DEFINE_EXPR_UNARY_FUNCTION(sqrt)
935
+
936
+ #undef _DEFINE_EXPR_UNARY_FUNCTION
937
+
938
+
939
+ #define _DEFINE_EXPR_BINARY_FUNCTION(_Name) \
940
+ template<class _Dom1, class _Dom2> \
941
+ inline _Expr<_BinFunClos<_Expr,_Expr,_Dom1,_Dom2>,typename _Dom1::value_type>\
942
+ _Name (const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \
943
+ const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \
944
+ { \
945
+ typedef typename _Dom1::value_type _Tp; \
946
+ typedef _BinFunClos<_Expr,_Expr,_Dom1,_Dom2> _Closure; \
947
+ return _Expr<_Closure,_Tp> \
948
+ (_Closure (__e1 (), __e2 (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
949
+ } \
950
+ \
951
+ template<class _Dom> \
952
+ inline _Expr<_BinFunClos<_Expr,_ValArray,_Dom,typename _Dom::value_type>, \
953
+ typename _Dom::value_type> \
954
+ _Name (const _Expr<_Dom,typename _Dom::value_type>& __e, \
955
+ const valarray<typename _Dom::value_type>& __v) \
956
+ { \
957
+ typedef typename _Dom::value_type _Tp; \
958
+ typedef _BinFunClos<_Expr,_ValArray,_Dom,_Tp> _Closure; \
959
+ return _Expr<_Closure,_Tp> \
960
+ (_Closure (__e (), __v, (_Tp(*)(_Tp, _Tp))(&_Name))); \
961
+ } \
962
+ \
963
+ template<class _Dom> \
964
+ inline _Expr<_BinFunClos<_ValArray,_Expr,typename _Dom::value_type,_Dom>, \
965
+ typename _Dom::value_type> \
966
+ _Name (const valarray<typename _Dom::valarray>& __v, \
967
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
968
+ { \
969
+ typedef typename _Dom::value_type _Tp; \
970
+ typedef _BinFunClos<_ValArray,_Expr,_Tp,_Dom> _Closure; \
971
+ return _Expr<_Closure,_Tp> \
972
+ (_Closure (__v, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
973
+ } \
974
+ \
975
+ template<class _Dom> \
976
+ inline _Expr<_BinFunClos<_Expr,_Constant,_Dom,typename _Dom::value_type>, \
977
+ typename _Dom::value_type> \
978
+ _Name (const _Expr<_Dom, typename _Dom::value_type>& __e, \
979
+ const typename _Dom::value_type& __t) \
980
+ { \
981
+ typedef typename _Dom::value_type _Tp; \
982
+ typedef _BinFunClos<_Expr,_Constant,_Dom,_Tp> _Closure; \
983
+ return _Expr<_Closure,_Tp> \
984
+ (_Closure (__e (), __t, (_Tp(*)(_Tp, _Tp))(&_Name))); \
985
+ } \
986
+ \
987
+ template<class _Dom> \
988
+ inline _Expr<_BinFunClos<_Constant,_Expr,typename _Dom::value_type,_Dom>, \
989
+ typename _Dom::value_type> \
990
+ _Name (const typename _Dom::value_type& __t, \
991
+ const _Expr<_Dom,typename _Dom::value_type>& __e) \
992
+ { \
993
+ typedef typename _Dom::value_type _Tp; \
994
+ typedef _BinFunClos<_Constant,_Expr,_Tp,_Dom> _Closure; \
995
+ return _Expr<_Closure,_Tp> \
996
+ (_Closure (__t, __e (), (_Tp(*)(_Tp, _Tp))(&_Name))); \
997
+ } \
998
+ \
999
+ template<typename _Tp> \
1000
+ inline _Expr<_BinFunClos<_ValArray,_ValArray,_Tp,_Tp>, _Tp> \
1001
+ _Name (const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
1002
+ { \
1003
+ typedef _BinFunClos<_ValArray,_ValArray,_Tp,_Tp> _Closure; \
1004
+ return _Expr<_Closure,_Tp> \
1005
+ (_Closure (__v, __w, (_Tp(*)(_Tp,_Tp))(&_Name))); \
1006
+ } \
1007
+ \
1008
+ template<typename _Tp> \
1009
+ inline _Expr<_BinFunClos<_ValArray,_Constant,_Tp,_Tp>,_Tp> \
1010
+ _Name (const valarray<_Tp>& __v, const _Tp& __t) \
1011
+ { \
1012
+ typedef _BinFunClos<_ValArray,_Constant,_Tp,_Tp> _Closure; \
1013
+ return _Expr<_Closure,_Tp> \
1014
+ (_Closure (__v, __t, (_Tp(*)(_Tp,_Tp))(&_Name))); \
1015
+ } \
1016
+ \
1017
+ template<typename _Tp> \
1018
+ inline _Expr<_BinFunClos<_Constant,_ValArray,_Tp,_Tp>,_Tp> \
1019
+ _Name (const _Tp& __t, const valarray<_Tp>& __v) \
1020
+ { \
1021
+ typedef _BinFunClos<_Constant,_ValArray,_Tp,_Tp> _Closure; \
1022
+ return _Expr<_Closure,_Tp> \
1023
+ (_Closure (__t, __v, (_Tp(*)(_Tp,_Tp))(&_Name))); \
1024
+ }
1025
+
1026
+ _DEFINE_EXPR_BINARY_FUNCTION(atan2)
1027
+ _DEFINE_EXPR_BINARY_FUNCTION(pow)
1028
+
1029
+ #undef _DEFINE_EXPR_BINARY_FUNCTION
1030
+
1031
+ #endif // _CPP_VALARRAY_META_H
1032
+
1033
+ // Local Variables:
1034
+ // mode:c++
1035
+ // End: