An object bearing information about the type expected from some operation. If a complex function call will return an object of a certain type depending on runtime circumstances, it may not always be desirable, or even possible, to start the operation, wait for the returned object, and perform a dynamic_cast to see what it is. Instead, the class can provide another function which tells you which datatype to expect given the parameters you would pass to the complex function. This can be used as follows:
class Foo :
public BaseClass { ... };
class Bar :
public BaseClass { ... };
if (et->is<
Foo>()) std::cout <<
"Operation will return a Foo object\n";
if (et->is<
Bar>()) std::cout <<
"Operation will return a Bar object\n";
BaseClass::Ptr result = complex_op.execute(params);
std::cout << result << "\n";
- See also
- ExpectedTypeIs<T> for how to write an expectedReturnType function as used in the code example.
Definition at line 58 of file ExpectedType.h.