|
LibSWOC++ 1.5.14
Solid Wall of C++
|


Go to the source code of this file.
Classes | |
| struct | swoc::meta::CaseTag< N > |
| Case hierarchy. More... | |
| struct | swoc::meta::CaseTag< 0 > |
| Case hierarchy anchor. More... | |
| struct | swoc::meta::vary< Args > |
| struct | swoc::meta::type_list< Types > |
| struct | swoc::meta::let< T > |
Namespaces | |
| namespace | swoc |
| For template deduction guides. | |
Functions | |
| template<typename T> | |
| T | swoc::meta::TypeFunc () |
| template<typename T, typename U> | |
| constexpr auto | swoc::meta::eraser (U &&u) -> U |
| template<typename... Args> | |
| swoc::meta::vary (Args...) -> vary< Args... > | |
| Template argument deduction guide (C++17 required). | |
Meta programming support utilities.
Definition in file swoc_meta.h.
|
constexpr |
Template parameter eraser.
| T | Parameter to erase (pass explicitly) |
| U | Parameter for forwarded value (implicit) |
| u | Forward value |
This has no effect on u but fools the compiler in to thinking T has been used. This avoids metaprogramming issues with unused template parameters.
Suppose an API has changed a function from "cheer_for_delain" to "cheer_delain". To handle this the metacase support is used, but there is no apparent template parameter. A fake one can be used and defaulted to void. But that creates the unused template parameter warning. This is fixed by doing something to erase the template parameter V while forwarding parameter x. The result is a function f that calls the correct function automatically. Note this can't be in the body of the function because even for SFINAE the function body must compile and the variant with the wrong function will fail.
Definition at line 148 of file swoc_meta.h.
| T swoc::meta::TypeFunc | ( | ) |
A typed function for use in decltype.
| T | The desired type. |
This function has no implementation. It should be used only inside decltype when a specific type (rather than the type of an expression) is needed. For a type T that has a expression default constructor this can be used.
But if there is no default constructor this will not compile. This is a work around, so the previous expression would be
Note this can also be a problem for even built in types like unsigned long for which the expression
does not compile.