|
| 1 | += Reference |
| 2 | +:mrdocs: |
| 3 | + |
| 4 | +[#index] |
| 5 | +== Global namespace |
| 6 | + |
| 7 | + |
| 8 | +=== Namespaces |
| 9 | + |
| 10 | +[cols=1] |
| 11 | +|=== |
| 12 | +| Name |
| 13 | + |
| 14 | +| <<B,`B`>> |
| 15 | +|=== |
| 16 | +=== Types |
| 17 | + |
| 18 | +[cols=2] |
| 19 | +|=== |
| 20 | +| Name | Description |
| 21 | + |
| 22 | +| <<A-09,`A`>> |
| 23 | +| The partial specialization of A is enabled via a template parameter |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +| <<A-02,`A<T, void>`>> |
| 28 | +| Specialization for floating point types |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +|=== |
| 33 | +=== Functions |
| 34 | + |
| 35 | +[cols=2] |
| 36 | +|=== |
| 37 | +| Name | Description |
| 38 | + |
| 39 | +| <<f1,`f1`>> |
| 40 | +| Enabled via return type |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +| <<f10,`f10`>> |
| 45 | +| Enabled via type template parameter |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +| <<f2,`f2`>> |
| 50 | +| Enabling a specified return type |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +| <<f3,`f3`>> |
| 55 | +| Enabling a specified return type in another namespace |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +| <<f4,`f4`>> |
| 60 | +| Enabled via return type with std::enable_if |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +| <<f5,`f5`>> |
| 65 | +| Enabled via a non‐type template parameter with helper |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +| <<f6,`f6`>> |
| 70 | +| Enabled via a non‐type template parameter without helper |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +| <<f7,`f7`>> |
| 75 | +| Enabled via a non‐type template parameter using int instead of bool |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +| <<f8,`f8`>> |
| 80 | +| Enabled via parameter without helper |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | +| <<f9,`f9`>> |
| 85 | +| Enabled via parameter with helper |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +|=== |
| 90 | + |
| 91 | +[#B] |
| 92 | +== B |
| 93 | + |
| 94 | + |
| 95 | +=== Types |
| 96 | + |
| 97 | +[cols=1] |
| 98 | +|=== |
| 99 | +| Name |
| 100 | + |
| 101 | +| <<B-C,`C`>> |
| 102 | +|=== |
| 103 | + |
| 104 | +[#B-C] |
| 105 | +== <<B,B>>::C |
| 106 | + |
| 107 | + |
| 108 | +=== Synopsis |
| 109 | + |
| 110 | + |
| 111 | +Declared in `<sfinae.cpp>` |
| 112 | + |
| 113 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 114 | +---- |
| 115 | +struct C; |
| 116 | +---- |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +[#A-09] |
| 122 | +== A |
| 123 | + |
| 124 | + |
| 125 | +The partial specialization of A is enabled via a template parameter |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +=== Synopsis |
| 130 | + |
| 131 | + |
| 132 | +Declared in `<sfinae.cpp>` |
| 133 | + |
| 134 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 135 | +---- |
| 136 | +template< |
| 137 | + class T, |
| 138 | + class Enable = void> |
| 139 | +class A; |
| 140 | +---- |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | +[#A-02] |
| 146 | +== A<T, void> |
| 147 | + |
| 148 | + |
| 149 | +Specialization for floating point types |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | +=== Synopsis |
| 154 | + |
| 155 | + |
| 156 | +Declared in `<sfinae.cpp>` |
| 157 | + |
| 158 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 159 | +---- |
| 160 | +template<class T> |
| 161 | +class <<A-09,A>><T, void>; |
| 162 | +---- |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | +[#f1] |
| 168 | +== f1 |
| 169 | + |
| 170 | + |
| 171 | +Enabled via return type |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | +=== Synopsis |
| 176 | + |
| 177 | + |
| 178 | +Declared in `<sfinae.cpp>` |
| 179 | + |
| 180 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 181 | +---- |
| 182 | +template<class T> |
| 183 | +T |
| 184 | +f1(T value); |
| 185 | +---- |
| 186 | + |
| 187 | +[#f10] |
| 188 | +== f10 |
| 189 | + |
| 190 | + |
| 191 | +Enabled via type template parameter |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | +=== Synopsis |
| 196 | + |
| 197 | + |
| 198 | +Declared in `<sfinae.cpp>` |
| 199 | + |
| 200 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 201 | +---- |
| 202 | +template< |
| 203 | + class T, |
| 204 | + typename = void> |
| 205 | +void |
| 206 | +f10(T* t); |
| 207 | +---- |
| 208 | + |
| 209 | +=== Description |
| 210 | + |
| 211 | + |
| 212 | +This pattern should not be used because the function signature is unmodified and therefore only supports one overload. |
| 213 | + |
| 214 | +It's a common mistake is to declare two function templates that differ only in their default template arguments. |
| 215 | + |
| 216 | +This does not work because the declarations are treated as redeclarations of the same function template (default template arguments are not accounted for in function template equivalence). |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | +[#f2] |
| 221 | +== f2 |
| 222 | + |
| 223 | + |
| 224 | +Enabling a specified return type |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | +=== Synopsis |
| 229 | + |
| 230 | + |
| 231 | +Declared in `<sfinae.cpp>` |
| 232 | + |
| 233 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 234 | +---- |
| 235 | +template<class T> |
| 236 | +int |
| 237 | +f2(T value); |
| 238 | +---- |
| 239 | + |
| 240 | +[#f3] |
| 241 | +== f3 |
| 242 | + |
| 243 | + |
| 244 | +Enabling a specified return type in another namespace |
| 245 | + |
| 246 | + |
| 247 | + |
| 248 | +=== Synopsis |
| 249 | + |
| 250 | + |
| 251 | +Declared in `<sfinae.cpp>` |
| 252 | + |
| 253 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 254 | +---- |
| 255 | +template<class T> |
| 256 | +<<B,B>>::<<B-C,C>> |
| 257 | +f3(T value); |
| 258 | +---- |
| 259 | + |
| 260 | +[#f4] |
| 261 | +== f4 |
| 262 | + |
| 263 | + |
| 264 | +Enabled via return type with std::enable_if |
| 265 | + |
| 266 | + |
| 267 | + |
| 268 | +=== Synopsis |
| 269 | + |
| 270 | + |
| 271 | +Declared in `<sfinae.cpp>` |
| 272 | + |
| 273 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 274 | +---- |
| 275 | +template<class T> |
| 276 | +T |
| 277 | +f4(T value); |
| 278 | +---- |
| 279 | + |
| 280 | +[#f5] |
| 281 | +== f5 |
| 282 | + |
| 283 | + |
| 284 | +Enabled via a non‐type template parameter with helper |
| 285 | + |
| 286 | + |
| 287 | + |
| 288 | +=== Synopsis |
| 289 | + |
| 290 | + |
| 291 | +Declared in `<sfinae.cpp>` |
| 292 | + |
| 293 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 294 | +---- |
| 295 | +template< |
| 296 | + class T, |
| 297 | + bool = true> |
| 298 | +T |
| 299 | +f5(T value); |
| 300 | +---- |
| 301 | + |
| 302 | +[#f6] |
| 303 | +== f6 |
| 304 | + |
| 305 | + |
| 306 | +Enabled via a non‐type template parameter without helper |
| 307 | + |
| 308 | + |
| 309 | + |
| 310 | +=== Synopsis |
| 311 | + |
| 312 | + |
| 313 | +Declared in `<sfinae.cpp>` |
| 314 | + |
| 315 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 316 | +---- |
| 317 | +template< |
| 318 | + class T, |
| 319 | + bool = true> |
| 320 | +T |
| 321 | +f6(T value); |
| 322 | +---- |
| 323 | + |
| 324 | +[#f7] |
| 325 | +== f7 |
| 326 | + |
| 327 | + |
| 328 | +Enabled via a non‐type template parameter using int instead of bool |
| 329 | + |
| 330 | + |
| 331 | + |
| 332 | +=== Synopsis |
| 333 | + |
| 334 | + |
| 335 | +Declared in `<sfinae.cpp>` |
| 336 | + |
| 337 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 338 | +---- |
| 339 | +template< |
| 340 | + class T, |
| 341 | + int = 0> |
| 342 | +void |
| 343 | +f7(T value); |
| 344 | +---- |
| 345 | + |
| 346 | +[#f8] |
| 347 | +== f8 |
| 348 | + |
| 349 | + |
| 350 | +Enabled via parameter without helper |
| 351 | + |
| 352 | + |
| 353 | + |
| 354 | +=== Synopsis |
| 355 | + |
| 356 | + |
| 357 | +Declared in `<sfinae.cpp>` |
| 358 | + |
| 359 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 360 | +---- |
| 361 | +template<class T> |
| 362 | +T |
| 363 | +f8( |
| 364 | + T value, |
| 365 | + void* = 0); |
| 366 | +---- |
| 367 | + |
| 368 | +[#f9] |
| 369 | +== f9 |
| 370 | + |
| 371 | + |
| 372 | +Enabled via parameter with helper |
| 373 | + |
| 374 | + |
| 375 | + |
| 376 | +=== Synopsis |
| 377 | + |
| 378 | + |
| 379 | +Declared in `<sfinae.cpp>` |
| 380 | + |
| 381 | +[source,cpp,subs="verbatim,replacements,macros,-callouts"] |
| 382 | +---- |
| 383 | +template<class T> |
| 384 | +T |
| 385 | +f9( |
| 386 | + T value, |
| 387 | + void* = 0); |
| 388 | +---- |
| 389 | + |
| 390 | + |
| 391 | + |
| 392 | +[.small]#Created with https://www.mrdocs.com[MrDocs]# |
0 commit comments