1 // Copyright 2010 The RE2 Authors. All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #ifndef RE2_VARIADIC_FUNCTION_H_ 6 #define RE2_VARIADIC_FUNCTION_H_ 7 8 namespace re2 { 9 10 template <typename Result, typename Param0, typename Param1, typename Arg, 11 Result (*Func)(Param0, Param1, const Arg* const [], int count)> 12 class VariadicFunction2 { 13 public: VariadicFunction2()14 VariadicFunction2() {} 15 operator()16 Result operator()(Param0 p0, Param1 p1) const { 17 return Func(p0, p1, 0, 0); 18 } 19 operator()20 Result operator()(Param0 p0, Param1 p1, const Arg& a0) const { 21 const Arg* const args[] = { &a0 }; 22 return Func(p0, p1, args, 1); 23 } 24 operator()25 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1) const { 26 const Arg* const args[] = { &a0, &a1 }; 27 return Func(p0, p1, args, 2); 28 } 29 operator()30 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 31 const Arg& a2) const { 32 const Arg* const args[] = { &a0, &a1, &a2 }; 33 return Func(p0, p1, args, 3); 34 } 35 operator()36 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 37 const Arg& a2, const Arg& a3) const { 38 const Arg* const args[] = { &a0, &a1, &a2, &a3 }; 39 return Func(p0, p1, args, 4); 40 } 41 operator()42 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 43 const Arg& a2, const Arg& a3, const Arg& a4) const { 44 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4 }; 45 return Func(p0, p1, args, 5); 46 } 47 operator()48 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 49 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5) const { 50 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5 }; 51 return Func(p0, p1, args, 6); 52 } 53 operator()54 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 55 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 56 const Arg& a6) const { 57 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6 }; 58 return Func(p0, p1, args, 7); 59 } 60 operator()61 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 62 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 63 const Arg& a6, const Arg& a7) const { 64 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7 }; 65 return Func(p0, p1, args, 8); 66 } 67 operator()68 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 69 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 70 const Arg& a6, const Arg& a7, const Arg& a8) const { 71 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8 }; 72 return Func(p0, p1, args, 9); 73 } 74 operator()75 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 76 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 77 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9) const { 78 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 79 &a9 }; 80 return Func(p0, p1, args, 10); 81 } 82 operator()83 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 84 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 85 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 86 const Arg& a10) const { 87 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 88 &a9, &a10 }; 89 return Func(p0, p1, args, 11); 90 } 91 operator()92 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 93 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 94 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 95 const Arg& a10, const Arg& a11) const { 96 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 97 &a9, &a10, &a11 }; 98 return Func(p0, p1, args, 12); 99 } 100 operator()101 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 102 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 103 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 104 const Arg& a10, const Arg& a11, const Arg& a12) const { 105 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 106 &a9, &a10, &a11, &a12 }; 107 return Func(p0, p1, args, 13); 108 } 109 operator()110 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 111 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 112 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 113 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13) const { 114 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 115 &a9, &a10, &a11, &a12, &a13 }; 116 return Func(p0, p1, args, 14); 117 } 118 operator()119 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 120 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 121 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 122 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 123 const Arg& a14) const { 124 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 125 &a9, &a10, &a11, &a12, &a13, &a14 }; 126 return Func(p0, p1, args, 15); 127 } 128 operator()129 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 130 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 131 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 132 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 133 const Arg& a14, const Arg& a15) const { 134 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 135 &a9, &a10, &a11, &a12, &a13, &a14, &a15 }; 136 return Func(p0, p1, args, 16); 137 } 138 operator()139 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 140 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 141 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 142 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 143 const Arg& a14, const Arg& a15, const Arg& a16) const { 144 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 145 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16 }; 146 return Func(p0, p1, args, 17); 147 } 148 operator()149 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 150 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 151 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 152 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 153 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17) const { 154 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 155 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17 }; 156 return Func(p0, p1, args, 18); 157 } 158 operator()159 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 160 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 161 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 162 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 163 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 164 const Arg& a18) const { 165 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 166 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18 }; 167 return Func(p0, p1, args, 19); 168 } 169 operator()170 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 171 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 172 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 173 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 174 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 175 const Arg& a18, const Arg& a19) const { 176 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 177 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19 }; 178 return Func(p0, p1, args, 20); 179 } 180 operator()181 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 182 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 183 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 184 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 185 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 186 const Arg& a18, const Arg& a19, const Arg& a20) const { 187 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 188 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, 189 &a20 }; 190 return Func(p0, p1, args, 21); 191 } 192 operator()193 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 194 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 195 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 196 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 197 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 198 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21) const { 199 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 200 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 201 &a21 }; 202 return Func(p0, p1, args, 22); 203 } 204 operator()205 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 206 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 207 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 208 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 209 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 210 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 211 const Arg& a22) const { 212 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 213 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 214 &a21, &a22 }; 215 return Func(p0, p1, args, 23); 216 } 217 operator()218 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 219 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 220 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 221 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 222 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 223 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 224 const Arg& a22, const Arg& a23) const { 225 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 226 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 227 &a21, &a22, &a23 }; 228 return Func(p0, p1, args, 24); 229 } 230 operator()231 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 232 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 233 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 234 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 235 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 236 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 237 const Arg& a22, const Arg& a23, const Arg& a24) const { 238 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 239 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 240 &a21, &a22, &a23, &a24 }; 241 return Func(p0, p1, args, 25); 242 } 243 operator()244 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 245 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 246 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 247 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 248 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 249 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 250 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25) const { 251 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 252 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 253 &a21, &a22, &a23, &a24, &a25 }; 254 return Func(p0, p1, args, 26); 255 } 256 operator()257 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 258 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 259 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 260 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 261 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 262 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 263 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25, 264 const Arg& a26) const { 265 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 266 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 267 &a21, &a22, &a23, &a24, &a25, &a26 }; 268 return Func(p0, p1, args, 27); 269 } 270 operator()271 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 272 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 273 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 274 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 275 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 276 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 277 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25, 278 const Arg& a26, const Arg& a27) const { 279 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 280 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 281 &a21, &a22, &a23, &a24, &a25, &a26, &a27 }; 282 return Func(p0, p1, args, 28); 283 } 284 operator()285 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 286 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 287 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 288 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 289 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 290 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 291 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25, 292 const Arg& a26, const Arg& a27, const Arg& a28) const { 293 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 294 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 295 &a21, &a22, &a23, &a24, &a25, &a26, &a27, &a28 }; 296 return Func(p0, p1, args, 29); 297 } 298 operator()299 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 300 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 301 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 302 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 303 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 304 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 305 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25, 306 const Arg& a26, const Arg& a27, const Arg& a28, const Arg& a29) const { 307 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 308 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 309 &a21, &a22, &a23, &a24, &a25, &a26, &a27, &a28, &a29 }; 310 return Func(p0, p1, args, 30); 311 } 312 operator()313 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 314 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 315 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 316 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 317 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 318 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 319 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25, 320 const Arg& a26, const Arg& a27, const Arg& a28, const Arg& a29, 321 const Arg& a30) const { 322 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 323 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 324 &a21, &a22, &a23, &a24, &a25, &a26, &a27, &a28, &a29, &a30 }; 325 return Func(p0, p1, args, 31); 326 } 327 operator()328 Result operator()(Param0 p0, Param1 p1, const Arg& a0, const Arg& a1, 329 const Arg& a2, const Arg& a3, const Arg& a4, const Arg& a5, 330 const Arg& a6, const Arg& a7, const Arg& a8, const Arg& a9, 331 const Arg& a10, const Arg& a11, const Arg& a12, const Arg& a13, 332 const Arg& a14, const Arg& a15, const Arg& a16, const Arg& a17, 333 const Arg& a18, const Arg& a19, const Arg& a20, const Arg& a21, 334 const Arg& a22, const Arg& a23, const Arg& a24, const Arg& a25, 335 const Arg& a26, const Arg& a27, const Arg& a28, const Arg& a29, 336 const Arg& a30, const Arg& a31) const { 337 const Arg* const args[] = { &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, 338 &a9, &a10, &a11, &a12, &a13, &a14, &a15, &a16, &a17, &a18, &a19, &a20, 339 &a21, &a22, &a23, &a24, &a25, &a26, &a27, &a28, &a29, &a30, &a31 }; 340 return Func(p0, p1, args, 32); 341 } 342 }; 343 344 } // namespace re2 345 346 #endif // RE2_VARIADIC_FUNCTION_H_ 347