|
BDE 4.14.0 Production release
|
Macros | |
| #define | bslmf_IsNil bslmf::IsNil |
| This alias is defined for backward compatibility. | |
Typedefs | |
| typedef bslmf::Nil | bslmf_Nil |
| This alias is defined for backward compatibility. | |
Provide a nil type.
bslmf::Nil is mainly used for template meta-programming. It is useful for providing defaults for template parameters and terminating template recursions. bslmf::Nil can also be used to represent an unset state (i.e., nil) in components that require one.
The following usage illustrates a typical use of bslmf::Nil as a default template parameter for another meta-function.
Next, we can use the my_If meta-function to implement a print function that checks whether a type has a print method (using a fictitious meta-function my_IsPrintable), and print the value. Note the use of bslmf::Nil as the type for overloading:
Using the above functions, the following code:
Will print the following to stdout:
Finally, the bslmf::IsNil meta-function returns true if the type passed to it is bslmf::Nil, and false otherwise:
| #define bslmf_IsNil bslmf::IsNil |
| typedef bslmf::Nil bslmf_Nil |